{"id":24765922,"url":"https://github.com/infinitensor/digit-layout","last_synced_at":"2025-10-11T14:31:29.913Z","repository":{"id":245273841,"uuid":"818055045","full_name":"InfiniTensor/digit-layout","owner":"InfiniTensor","description":"Define memory layout of digital types as `[sign|exponent|mantissa; N]`","archived":false,"fork":false,"pushed_at":"2025-05-15T02:35:08.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-15T03:38:16.209Z","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/InfiniTensor.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2024-06-21T02:23:47.000Z","updated_at":"2025-05-15T02:34:51.000Z","dependencies_parsed_at":"2025-05-15T03:42:44.703Z","dependency_job_id":null,"html_url":"https://github.com/InfiniTensor/digit-layout","commit_stats":null,"previous_names":["ydrmaster/digit-layout","infinitensor/digit-layout"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/InfiniTensor/digit-layout","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InfiniTensor%2Fdigit-layout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InfiniTensor%2Fdigit-layout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InfiniTensor%2Fdigit-layout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InfiniTensor%2Fdigit-layout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/InfiniTensor","download_url":"https://codeload.github.com/InfiniTensor/digit-layout/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InfiniTensor%2Fdigit-layout/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279007457,"owners_count":26084313,"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-11T02:00:06.511Z","response_time":55,"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":[],"created_at":"2025-01-28T23:17:41.802Z","updated_at":"2025-10-11T14:31:29.909Z","avatar_url":"https://github.com/InfiniTensor.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# digit-layout\n\n[![CI](https://github.com/InfiniTensor/digit-layout/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/InfiniTensor/digit-layout/actions)\n[![Latest version](https://img.shields.io/crates/v/digit-layout.svg)](https://crates.io/crates/digit-layout)\n[![Documentation](https://docs.rs/digit-layout/badge.svg)](https://docs.rs/digit-layout)\n[![license](https://img.shields.io/github/license/InfiniTensor/digit-layout)](https://mit-license.org/)\n[![codecov](https://codecov.io/gh/InfiniTensor/digit-layout/branch/main/graph/badge.svg)](https://codecov.io/gh/InfiniTensor/digit-layout)\n![GitHub repo size](https://img.shields.io/github/repo-size/InfiniTensor/digit-layout)\n![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/InfiniTensor/digit-layout)\n\n[![GitHub Issues](https://img.shields.io/github/issues/InfiniTensor/digit-layout)](https://github.com/InfiniTensor/digit-layout/issues)\n[![GitHub Pull Requests](https://img.shields.io/github/issues-pr/InfiniTensor/digit-layout)](https://github.com/InfiniTensor/digit-layout/pulls)\n![GitHub contributors](https://img.shields.io/github/contributors/InfiniTensor/digit-layout)\n![GitHub commit activity](https://img.shields.io/github/commit-activity/m/InfiniTensor/digit-layout)\n\n这个库提供了一个统一的数据类型定义，可以高效地编码类型信息，避免重复定义数据类型。\n\n## 特性\n\n- 支持无符号整数类型；\n- 支持浮点数类型；\n- 支持自定义命名类型；\n- 紧凑的内存布局；\n- 无标准库依赖（no_std）；\n- 可选的 half 浮点数支持；\n\n## 使用示例\n\n### 基本用法\n\n```rust\nuse digit_layout::{DigitLayout, LayoutContent};\n\n// 创建无符号整数类型布局\nlet u8_layout = DigitLayout::unsigned(8, 1);\nassert_eq!(u8_layout.to_string(), \"u8\");\n\n// 创建浮点数类型布局\nlet f32_layout = DigitLayout::real(8, 23, 1);\nassert_eq!(f32_layout.to_string(), \"f32_e8m23\");\n\n// 创建自定义类型布局\nlet custom_layout = DigitLayout::named(\"custom\", 1, 4);\nassert_eq!(custom_layout.to_string(), \"custom\");\n```\n\n### 数组类型\n\n```rust\nuse digit_layout::DigitLayout;\n\n// 创建无符号整数数组布局\nlet u8_array = DigitLayout::unsigned(8, 4);\nassert_eq!(u8_array.to_string(), \"[u8; 4]\");\n\n// 创建浮点数数组布局\nlet f32_array = DigitLayout::real(8, 23, 4);\nassert_eq!(f32_array.to_string(), \"[f32_e8m23; 4]\");\n```\n\n### 解码布局\n\n```rust\nuse digit_layout::{DigitLayout, LayoutContent};\n\n// 解码无符号整数布局\nlet u8_layout = DigitLayout::unsigned(8, 1);\nmatch u8_layout.decode() {\n    LayoutContent::Unsigned { width } =\u003e {\n        assert_eq!(width, 8);\n    }\n    _ =\u003e panic!(\"Expected unsigned layout\"),\n}\n\n// 解码浮点数布局\nlet f32_layout = DigitLayout::real(8, 23, 1);\nmatch f32_layout.decode() {\n    LayoutContent::Real { exponent, mantissa } =\u003e {\n        assert_eq!(exponent, 8);\n        assert_eq!(mantissa, 23);\n    }\n    _ =\u003e panic!(\"Expected real layout\"),\n}\n```\n\n## 性能测试\n\n项目包含一个性能测试示例，可以测量各种操作的执行时间。运行性能测试：\n\n```bash\ncargo run --example benchmark\n```\n\n性能测试会测量以下操作的执行时间：\n\n1. 创建布局\n   - 创建无符号整数布局；\n   - 创建浮点数布局；\n   - 创建自定义布局；\n\n2. 解码布局\n   - 解码无符号整数布局；\n   - 解码浮点数布局；\n   - 解码自定义布局；\n\n测试结果会显示每个操作的平均执行时间。\n\n## 文档\n\n完整的 API 文档可以在 [docs.rs](https://docs.rs/digit-layout) 上找到。\n\n## 贡献\n\n欢迎提交 Issue 和 Pull Request！\n\n## 许可证\n\n本项目采用 MIT 许可证 - 详见 [LICENSE](LICENSE) 文件。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfinitensor%2Fdigit-layout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finfinitensor%2Fdigit-layout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfinitensor%2Fdigit-layout/lists"}