{"id":21220725,"url":"https://github.com/InfiniTensor/ndarray-layout","last_synced_at":"2025-07-10T12:31:02.792Z","repository":{"id":256868916,"uuid":"852161168","full_name":"InfiniTensor/ndarray-layout","owner":"InfiniTensor","description":"定义张量和元信息变换","archived":false,"fork":false,"pushed_at":"2025-04-29T13:32:30.000Z","size":98,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-08T05:59:42.264Z","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-09-04T10:30:41.000Z","updated_at":"2025-04-29T13:36:28.000Z","dependencies_parsed_at":"2024-09-13T14:34:23.549Z","dependency_job_id":"9876a370-de5d-4c6f-9095-5ea32cc3ad23","html_url":"https://github.com/InfiniTensor/ndarray-layout","commit_stats":null,"previous_names":["ydrmaster/ndarray-layout"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/InfiniTensor/ndarray-layout","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InfiniTensor%2Fndarray-layout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InfiniTensor%2Fndarray-layout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InfiniTensor%2Fndarray-layout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InfiniTensor%2Fndarray-layout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/InfiniTensor","download_url":"https://codeload.github.com/InfiniTensor/ndarray-layout/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InfiniTensor%2Fndarray-layout/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264578850,"owners_count":23631552,"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-11-20T22:13:51.713Z","updated_at":"2025-07-10T12:31:02.787Z","avatar_url":"https://github.com/InfiniTensor.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# ndarray-layout\n\n[![CI](https://github.com/InfiniTensor/ndarray-layout/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/InfiniTensor/ndarray-layout/actions)\n[![Latest version](https://img.shields.io/crates/v/ndarray-layout.svg)](https://crates.io/crates/ndarray-layout)\n[![Documentation](https://docs.rs/ndarray-layout/badge.svg)](https://docs.rs/ndarray-layout)\n[![license](https://img.shields.io/github/license/InfiniTensor/ndarray-layout)](https://mit-license.org/)\n[![codecov](https://codecov.io/github/InfiniTensor/ndarray-layout/branch/main/graph/badge.svg)](https://codecov.io/github/InfiniTensor/ndarray-layout)\n![GitHub repo size](https://img.shields.io/github/repo-size/InfiniTensor/ndarray-layout)\n![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/InfiniTensor/ndarray-layout)\n\n[![GitHub Issues](https://img.shields.io/github/issues/InfiniTensor/ndarray-layout)](https://github.com/InfiniTensor/ndarray-layout/issues)\n[![GitHub Pull Requests](https://img.shields.io/github/issues-pr/InfiniTensor/ndarray-layout)](https://github.com/InfiniTensor/ndarray-layout/pulls)\n![GitHub contributors](https://img.shields.io/github/contributors/InfiniTensor/ndarray-layout)\n![GitHub commit activity](https://img.shields.io/github/commit-activity/m/InfiniTensor/ndarray-layout)\n\n*ndarray-layout* 是一个用于处理多维数组布局的 crate，它提供了 `ArrayLayout` 结构体，用于高效管理和操作多维数组的元信息，如形状、步长和偏移量等。这个库在处理多维数组时，提供了灵活且高效的布局管理方式，能够满足不同场景下对数组布局的操作需求。\n\n## 主要功能特点\n\n### 多维数组布局管理\n\n- `ArrayLayout` 结构体支持指定任意维度的数组布局，通过 `new` 方法可以创建具有指定形状、步长和偏移量的布局;\n- 提供 `new_contiguous` 方法，用于创建连续的数组布局，支持大端序（`BigEndian`）和小端序（`LittleEndian`）两种存储顺序;\n\n### 元信息访问\n\n- 提供便捷的方法来访问数组布局的元信息，如 `ndim`、`offset`、`shape` 和 `strides` 等;\n- 支持计算数组元素的偏移量和数据范围，方便进行内存访问和数据处理;\n\n### 布局操作功能\n\n- 提供多种布局变换方法，如 `index`、`tile`、`transpose`、`merge` 和 `slice` 等，方便对数组布局进行各种变换操作;\n\n## 使用示例\n\n```rust\nuse ndarray_layout::{ArrayLayout, BroadcastArg};\n\n// 创建一个新的 `ArrayLayout` 实例。\n// 形状为 [1, 2, 3]，步长为 [12, 4, 1]，偏移量为 0。\nlet layout = ArrayLayout::\u003c3\u003e::new(\u0026[1, 2, 3], \u0026[12, 4, 1], 0);\n\n// 验证初始的形状和步长。\nassert_eq!(layout.shape(), \u0026[1, 2, 3]);\nassert_eq!(layout.strides(), \u0026[12, 4, 1]);\nassert_eq!(layout.offset(), 0);\n\n// 对第 0 维进行广播变换，广播次数为 4。\nlet broadcasted_layout = layout.broadcast(0, 4);\n\n// 验证广播变换后的形状和步长。\nassert_eq!(broadcasted_layout.shape(), \u0026[4, 2, 3]);\nassert_eq!(broadcasted_layout.strides(), \u0026[0, 4, 1]);\nassert_eq!(broadcasted_layout.offset(), 0);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FInfiniTensor%2Fndarray-layout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FInfiniTensor%2Fndarray-layout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FInfiniTensor%2Fndarray-layout/lists"}