[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-arogozhnikov--einops":3,"tool-arogozhnikov--einops":61},[4,18,26,36,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",146793,2,"2026-04-08T23:32:35",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108111,"2026-04-08T11:23:26",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":10,"last_commit_at":59,"category_tags":60,"status":17},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,"2026-04-06T11:19:32",[35,15,13,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":67,"readme_en":68,"readme_zh":69,"quickstart_zh":70,"use_case_zh":71,"hero_image_url":72,"owner_login":73,"owner_name":74,"owner_avatar_url":75,"owner_bio":76,"owner_company":77,"owner_location":78,"owner_email":77,"owner_twitter":77,"owner_website":79,"owner_url":80,"languages":81,"stars":98,"forks":99,"last_commit_at":100,"license":101,"difficulty_score":102,"env_os":103,"env_gpu":104,"env_ram":104,"env_deps":105,"category_tags":119,"github_topics":120,"view_count":32,"oss_zip_url":77,"oss_zip_packed_at":77,"status":17,"created_at":123,"updated_at":124,"faqs":125,"releases":156},5698,"arogozhnikov\u002Feinops","einops","Flexible and powerful tensor operations for readable and reliable code (for pytorch, jax, TF and others)","einops 是一个专为深度学习设计的张量操作库，旨在让代码更简洁、易读且可靠。它支持 PyTorch、JAX、TensorFlow、NumPy、MLX 等多种主流框架，提供了一套统一且强大的接口来处理高维张量。\n\n在深度学习研发中，开发者常需对张量进行重塑、转置、合并或拆分等操作。传统写法往往依赖晦涩的维度索引或冗长的链式调用，不仅难以阅读，还容易出错。einops 通过引入类似爱因斯坦求和约定（einsum）的声明式语法，让用户能用直观的符号描述张量变换逻辑，大幅降低理解成本和维护难度。无论是复杂的注意力机制还是多维数据重组，都能用寥寥数行清晰表达。\n\n该工具特别适合 AI 研究人员、算法工程师及深度学习开发者使用，尤其是那些频繁处理高维张量、追求代码优雅性与复现性的群体。其独特亮点包括：原生支持多种后端框架、无缝兼容 `torch.compile` 加速、内置 Packing\u002FUnpacking 高级操作，以及被 ICLR 2022 收录的学术背书。此外，社区中还提供了交互式教程和在线实验环境，帮助用户快速上手。如果你正在为繁琐的张量操作头疼，einops 或许能显著提升你的开发","einops 是一个专为深度学习设计的张量操作库，旨在让代码更简洁、易读且可靠。它支持 PyTorch、JAX、TensorFlow、NumPy、MLX 等多种主流框架，提供了一套统一且强大的接口来处理高维张量。\n\n在深度学习研发中，开发者常需对张量进行重塑、转置、合并或拆分等操作。传统写法往往依赖晦涩的维度索引或冗长的链式调用，不仅难以阅读，还容易出错。einops 通过引入类似爱因斯坦求和约定（einsum）的声明式语法，让用户能用直观的符号描述张量变换逻辑，大幅降低理解成本和维护难度。无论是复杂的注意力机制还是多维数据重组，都能用寥寥数行清晰表达。\n\n该工具特别适合 AI 研究人员、算法工程师及深度学习开发者使用，尤其是那些频繁处理高维张量、追求代码优雅性与复现性的群体。其独特亮点包括：原生支持多种后端框架、无缝兼容 `torch.compile` 加速、内置 Packing\u002FUnpacking 高级操作，以及被 ICLR 2022 收录的学术背书。此外，社区中还提供了交互式教程和在线实验环境，帮助用户快速上手。如果你正在为繁琐的张量操作头疼，einops 或许能显著提升你的开发效率与代码质量。","\n\u003C!--\n\u003Ca href='http:\u002F\u002Farogozhnikov.github.io\u002Fimages\u002Feinops\u002Feinops_video.mp4' >\n\u003Cdiv align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Farogozhnikov_einops_readme_94108b93fcc8.gif\" alt=\"einops package examples\" \u002F>\n  \u003Cbr>\n  \u003Csmall>\u003Ca href='http:\u002F\u002Farogozhnikov.github.io\u002Fimages\u002Feinops\u002Feinops_video.mp4'>This video in high quality (mp4)\u003C\u002Fa>\u003C\u002Fsmall>\n  \u003Cbr>\u003Cbr>\n\u003C\u002Fdiv>\n\u003C\u002Fa>\n-->\n\n\u003C!-- this link magically rendered as video on github readme, unfortunately not in docs -->\n\nhttps:\u002F\u002Fuser-images.githubusercontent.com\u002F6318811\u002F177030658-66f0eb5d-e136-44d8-99c9-86ae298ead5b.mp4\n\n\n\n\n# einops \n[![Run tests](https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Factions\u002Fworkflows\u002Frun_tests.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Factions\u002Fworkflows\u002Frun_tests.yml)\n[![PyPI version](https:\u002F\u002Fbadge.fury.io\u002Fpy\u002Feinops.svg)](https:\u002F\u002Fbadge.fury.io\u002Fpy\u002Feinops)\n[![Documentation](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fdocumentation-link-blue.svg)](https:\u002F\u002Feinops.rocks\u002F)\n![Supported python versions](https:\u002F\u002Fraw.githubusercontent.com\u002Farogozhnikov\u002Feinops\u002Fmain\u002Fdocs\u002Fresources\u002Fpython_badge.svg)\n\n\nFlexible and powerful tensor operations for readable and reliable code. \u003Cbr \u002F>\nSupports numpy, pytorch, jax, mlx and [others](#supported-frameworks).\n\n## Recent updates:\n\n- [einops playground](https:\u002F\u002Farogozhnikov.github.io\u002Fjupyterlite\u002Flab\u002Findex.html?download_github_folder=arogozhnikov\u002Feinops\u002Fdocs) can run 2 of 4 example notebooks right in your browser\n- 0.8.2: MLX backend added\n- 0.8.0: tinygrad backend added, small fixes\n- 0.7.0: no-hassle `torch.compile`, support of [array api standard](https:\u002F\u002Fdata-apis.org\u002Farray-api\u002Flatest\u002FAPI_specification\u002Findex.html) and more\n- 10'000🎉: github reports that more than 10k project use einops\n- einops 0.6.1: paddle backend added\n- einops 0.6 introduces [packing and unpacking](https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fblob\u002Fmain\u002Fdocs\u002F4-pack-and-unpack.ipynb)\n- einops 0.5: einsum is now a part of einops\n- [Einops paper](https:\u002F\u002Fopenreview.net\u002Fpdf?id=oapKSVM2bcj) is accepted for oral presentation at ICLR 2022 (yes, it worth reading).\n  Talk recordings are [available](https:\u002F\u002Ficlr.cc\u002Fvirtual\u002F2022\u002Foral\u002F6603)\n\n\n\u003Cdetails markdown=\"1\">\n\u003Csummary>Previous updates\u003C\u002Fsummary>\n- flax and oneflow backend added\n- torch.jit.script is supported for pytorch layers\n- powerful EinMix added to einops. [Einmix tutorial notebook](https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fblob\u002Fmain\u002Fdocs\u002F3-einmix-layer.ipynb) \n\u003C\u002Fdetails>\n\n\u003C!--\u003Cdiv align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Farogozhnikov_einops_readme_b297cf6447f5.png\" \n  alt=\"einops package logo\" width=\"250\" height=\"250\" \u002F>\n  \u003Cbr>\u003Cbr>\n\u003C\u002Fdiv> -->\n\n\n## Tweets \n\n> In case you need convincing arguments for setting aside time to learn about einsum and einops...\n[Tim Rocktäschel](https:\u002F\u002Ftwitter.com\u002F_rockt\u002Fstatus\u002F1230818967205425152)\n\n> Writing better code with PyTorch and einops 👌\n[Andrej Karpathy](https:\u002F\u002Ftwitter.com\u002Fkarpathy\u002Fstatus\u002F1290826075916779520)\n\n> Slowly but surely, einops is seeping in to every nook and cranny of my code. If you find yourself shuffling around bazillion dimensional tensors, this might change your life\n[Nasim Rahaman](https:\u002F\u002Ftwitter.com\u002Fnasim_rahaman\u002Fstatus\u002F1216022614755463169)\n\n[More testimonials](https:\u002F\u002Feinops.rocks\u002Fpages\u002Ftestimonials\u002F)\n\n\n## Contents\n\n- [Installation](#Installation)\n- [Documentation](https:\u002F\u002Feinops.rocks\u002F)\n- [Tutorial](#Tutorials)\n- [API micro-reference](#API)\n- [Why use einops](#Why-use-einops-notation)\n- [Supported frameworks](#Supported-frameworks)\n- [Citing](#Citing)\n- [Repository](https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops) and [discussions](https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fdiscussions)\n\n## Installation  \u003Ca name=\"Installation\">\u003C\u002Fa>\n\nPlain and simple:\n```bash\npip install einops\n```\n\n(`uv pip install einops` works as well)\n\n## Tutorials \u003Ca name=\"Tutorials\">\u003C\u002Fa>\n\nTutorials are the most convenient way to see `einops` in action\n\n- part 1: [einops fundamentals](https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fblob\u002Fmain\u002Fdocs\u002F1-einops-basics.ipynb)\n- part 2: [einops for deep learning](https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fblob\u002Fmain\u002Fdocs\u002F2-einops-for-deep-learning.ipynb)\n- part 3: [packing and unpacking](https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fblob\u002Fmain\u002Fdocs\u002F4-pack-and-unpack.ipynb)\n- part 4: [improve pytorch code with einops](http:\u002F\u002Feinops.rocks\u002Fpytorch-examples.html)\n\nKapil Sachdeva recorded a small [intro to einops](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=xGy75Pjsqzo).\n\n## API \u003Ca name=\"API\">\u003C\u002Fa>\n\n`einops` has a minimalistic yet powerful API.\n\nThree core operations provided ([einops tutorial](https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fblob\u002Fmain\u002Fdocs\u002F)\nshows those cover stacking, reshape, transposition, squeeze\u002Funsqueeze, repeat, tile, concatenate, view and numerous reductions)\n\n```python\nfrom einops import rearrange, reduce, repeat\n# rearrange elements according to the pattern\noutput_tensor = rearrange(input_tensor, 't b c -> b c t')\n# combine rearrangement and reduction\noutput_tensor = reduce(input_tensor, 'b c (h h2) (w w2) -> b h w c', 'mean', h2=2, w2=2)\n# copy along a new axis\noutput_tensor = repeat(input_tensor, 'h w -> h w c', c=3)\n```\n\nLater additions to the family are `pack` and `unpack` functions (better than stack\u002Fsplit\u002Fconcatenate):\n\n```python\nfrom einops import pack, unpack\n# pack and unpack allow reversibly 'packing' multiple tensors into one.\n# Packed tensors may be of different dimensionality:\npacked,  ps = pack([class_token_bc, image_tokens_bhwc, text_tokens_btc], 'b * c')\nclass_emb_bc, image_emb_bhwc, text_emb_btc = unpack(transformer(packed), ps, 'b * c')\n```\n\nFinally, einops provides einsum with a support of multi-lettered names:\n\n```python\nfrom einops import einsum, pack, unpack\n# einsum is like ... einsum, generic and flexible dot-product\n# but 1) axes can be multi-lettered  2) pattern goes last 3) works with multiple frameworks\nC = einsum(A, B, 'b t1 head c, b t2 head c -> b head t1 t2')\n```\n\n### EinMix\n\n`EinMix` is a generic linear layer, perfect for MLP Mixers and similar architectures.\n\n### Layers\n\nEinops provides layers (`einops` keeps a separate version for each framework) that reflect corresponding functions\n\n```python\nfrom einops.layers.torch      import Rearrange, Reduce\nfrom einops.layers.tensorflow import Rearrange, Reduce\nfrom einops.layers.flax       import Rearrange, Reduce\nfrom einops.layers.paddle     import Rearrange, Reduce\n```\n\n\u003Cdetails markdown=\"1\">\n\u003Csummary>Example of using layers within a pytorch model\u003C\u002Fsummary>\nExample given for pytorch, but code in other frameworks is almost identical\n\n```python \nfrom torch.nn import Sequential, Conv2d, MaxPool2d, Linear, ReLU\nfrom einops.layers.torch import Rearrange\n\nmodel = Sequential(\n    ...,\n    Conv2d(6, 16, kernel_size=5),\n    MaxPool2d(kernel_size=2),\n    # flattening without need to write forward\n    Rearrange('b c h w -> b (c h w)'),\n    Linear(16*5*5, 120),\n    ReLU(),\n    Linear(120, 10),\n)\n```\n\nNo more flatten needed!\n\nAdditionally, torch layers as those are script-able and compile-able.\nOperations [are torch.compile-able](https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fwiki\u002FUsing-torch.compile-with-einops),\n but not script-able due to limitations of torch.jit.script.\n\u003C\u002Fdetails>\n\n\n\n\n## Naming \u003Ca name=\"Naming\">\u003C\u002Fa>\n\n`einops` stands for Einstein-Inspired Notation for operations \n(though \"Einstein operations\" is more attractive and easier to remember).\n\nNotation was loosely inspired by Einstein summation (in particular by `numpy.einsum` operation).\n\n## Why use `einops` notation?! \u003Ca name=\"Why-use-einops-notation\">\u003C\u002Fa>\n\n\n### Semantic information (being verbose in expectations)\n\n```python\ny = x.view(x.shape[0], -1)\ny = rearrange(x, 'b c h w -> b (c h w)')\n```\nWhile these two lines are doing the same job in *some* context,\nthe second one provides information about the input and output.\nIn other words, `einops` focuses on interface: *what is the input and output*, not *how* the output is computed.\n\nThe next operation looks similar:\n\n```python\ny = rearrange(x, 'time c h w -> time (c h w)')\n```\nbut it gives the reader a hint:\nthis is not an independent batch of images we are processing,\nbut rather a sequence (video).\n\nSemantic information makes the code easier to read and maintain.\n\n### Convenient checks\n\nReconsider the same example:\n\n```python\ny = x.view(x.shape[0], -1) # x: (batch, 256, 19, 19)\ny = rearrange(x, 'b c h w -> b (c h w)')\n```\nThe second line checks that the input has four dimensions,\nbut you can also specify particular dimensions.\nThat's opposed to just writing comments about shapes since comments don't prevent mistakes,\nnot tested, and without code review tend to be outdated\n```python\ny = x.view(x.shape[0], -1) # x: (batch, 256, 19, 19)\ny = rearrange(x, 'b c h w -> b (c h w)', c=256, h=19, w=19)\n```\n\n### Result is strictly determined\n\nBelow we have at least two ways to define the depth-to-space operation\n```python\n# depth-to-space\nrearrange(x, 'b c (h h2) (w w2) -> b (c h2 w2) h w', h2=2, w2=2)\nrearrange(x, 'b c (h h2) (w w2) -> b (h2 w2 c) h w', h2=2, w2=2)\n```\nThere are at least four more ways to do it. Which one is used by the framework?\n\nThese details are ignored, since *usually* it makes no difference,\nbut it can make a big difference (e.g. if you use grouped convolutions in the next stage),\nand you'd like to specify this in your code.\n\n\n### Uniformity\n\n```python\nreduce(x, 'b c (x dx) -> b c x', 'max', dx=2)\nreduce(x, 'b c (x dx) (y dy) -> b c x y', 'max', dx=2, dy=3)\nreduce(x, 'b c (x dx) (y dy) (z dz) -> b c x y z', 'max', dx=2, dy=3, dz=4)\n```\nThese examples demonstrated that we don't use separate operations for 1d\u002F2d\u002F3d pooling,\nthose are all defined in a uniform way.\n\nSpace-to-depth and depth-to space are defined in many frameworks but how about width-to-height? Here you go:\n\n```python\nrearrange(x, 'b c h (w w2) -> b c (h w2) w', w2=2)\n```\n\n\n### Framework independent behavior\n\nEven simple functions are defined differently by different frameworks\n\n```python\ny = x.flatten() # or flatten(x)\n```\n\nSuppose `x`'s shape was `(3, 4, 5)`, then `y` has shape ...\n\n- numpy, pytorch, cupy, chainer, jax: `(60,)`\n- keras, tensorflow.layers, gluon: `(3, 20)`\n\n`einops` works the same way in all frameworks.\n\n\n### Independence of framework terminology\n\nExample: `tile` vs `repeat` causes lots of confusion. To copy image along width:\n```python\nnp.tile(image, (1, 2))    # in numpy\nimage.repeat(1, 2)        # pytorch's repeat ~ numpy's tile\n```\n\nWith einops you don't need to decipher which axis was repeated:\n```python\nrepeat(image, 'h w -> h (tile w)', tile=2)  # in numpy\nrepeat(image, 'h w -> h (tile w)', tile=2)  # in pytorch\nrepeat(image, 'h w -> h (tile w)', tile=2)  # in tf\nrepeat(image, 'h w -> h (tile w)', tile=2)  # in jax\nrepeat(image, 'h w -> h (tile w)', tile=2)  # in cupy\n... (etc.)\n```\n\n[Testimonials](https:\u002F\u002Feinops.rocks\u002Fpages\u002Ftestimonials\u002F) provide users' perspective on the same question.\n\n\n## Supported frameworks \u003Ca name=\"Supported-frameworks\">\u003C\u002Fa>\n\nEinops works with ...\n\n- [numpy](http:\u002F\u002Fwww.numpy.org\u002F)\n- [pytorch](https:\u002F\u002Fpytorch.org\u002F)\n- [tensorflow](https:\u002F\u002Fwww.tensorflow.org\u002F)\n- [jax](https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fjax)\n- [cupy](https:\u002F\u002Fgithub.com\u002Fcupy\u002Fcupy)\n- [flax](https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fflax) (community)\n- [paddle](https:\u002F\u002Fgithub.com\u002FPaddlePaddle\u002FPaddle) (community)\n- [oneflow](https:\u002F\u002Fgithub.com\u002FOneflow-Inc\u002Foneflow) (community)\n- [tinygrad](https:\u002F\u002Fgithub.com\u002Ftinygrad\u002Ftinygrad) (community)\n- [pytensor](https:\u002F\u002Fgithub.com\u002Fpymc-devs\u002Fpytensor) (community)\n\n\n\n```python\nfrom einops import rearrange  \n=> from einops.array_api import rearrange\n```\n\nBut actually it is even better: einops can be used with *any* framework that supports\n[Python array API standard](https:\u002F\u002Fdata-apis.org\u002Farray-api\u002Flatest\u002FAPI_specification\u002Findex.html),\nto name a few:\n\n- numpy >= 2.0\n- [MLX](https:\u002F\u002Fgithub.com\u002Fml-explore\u002Fmlx)  # yes, einops works with apple's framework\n- [pydata\u002Fsparse](https:\u002F\u002Fgithub.com\u002Fpydata\u002Fsparse) >= 0.15 # and works with sparse tensors\n- [cubed](https:\u002F\u002Fgithub.com\u002Fcubed-dev\u002Fcubed) # and with distributed tensors too\n- [quantco\u002Fndonnx](https:\u002F\u002Fgithub.com\u002FQuantco\u002Fndonnx)\n- jax\n- cupy\n- dask is supported via [array-api-compat](https:\u002F\u002Fgithub.com\u002Fdata-apis\u002Farray-api-compat)\n\n\n## Development\n\nDevcontainer is provided, this environment can be used locally, or on your server,\nor within github codespaces. \nTo start with devcontainers in vs code, clone repo, and click 'Reopen in Devcontainer'. \n\nStarting from einops 0.8.1, einops distributes tests as a part of package.\n\n```bash\n# pip install einops pytest\npython -m einops.tests.run_tests numpy pytorch jax --pip-install\n```\n\n`numpy pytorch jax` is an _example_, any subset of testable frameworks can be provided.\nEvery framework is tested against numpy, so it is a requirement for tests.\n\nSpecifying `--pip-install` will install requirements in current virtualenv,\nand should be omitted if dependencies are installed locally.\n\nTo build\u002Ftest docs:\n\n```bash\nhatch run docs:serve  # Serving on http:\u002F\u002Flocalhost:8000\u002F\n```\n\n\n## Citing einops \u003Ca name=\"Citing\">\u003C\u002Fa>\n\nPlease use the following bibtex record\n\n```text\n@inproceedings{\n    rogozhnikov2022einops,\n    title={Einops: Clear and Reliable Tensor Manipulations with Einstein-like Notation},\n    author={Alex Rogozhnikov},\n    booktitle={International Conference on Learning Representations},\n    year={2022},\n    url={https:\u002F\u002Fopenreview.net\u002Fforum?id=oapKSVM2bcj}\n}\n```\n\n\n## Supported python versions\n\n`einops` works with python 3.10 or later.\n","\u003C!--\n\u003Ca href='http:\u002F\u002Farogozhnikov.github.io\u002Fimages\u002Feinops\u002Feinops_video.mp4' >\n\u003Cdiv align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Farogozhnikov_einops_readme_94108b93fcc8.gif\" alt=\"einops package examples\" \u002F>\n  \u003Cbr>\n  \u003Csmall>\u003Ca href='http:\u002F\u002Farogozhnikov.github.io\u002Fimages\u002Feinops\u002Feinops_video.mp4'>此视频的高清版本（mp4）\u003C\u002Fa>\u003C\u002Fsmall>\n  \u003Cbr>\u003Cbr>\n\u003C\u002Fdiv>\n\u003C\u002Fa>\n-->\n\n\u003C!-- 此链接在 GitHub README 中神奇地渲染成了视频，但在文档中却未能如此 -->\n\nhttps:\u002F\u002Fuser-images.githubusercontent.com\u002F6318811\u002F177030658-66f0eb5d-e136-44d8-99c9-86ae298ead5b.mp4\n\n\n\n\n# einops \n[![运行测试](https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Factions\u002Fworkflows\u002Frun_tests.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Factions\u002Fworkflows\u002Frun_tests.yml)\n[![PyPI 版本](https:\u002F\u002Fbadge.fury.io\u002Fpy\u002Feinops.svg)](https:\u002F\u002Fbadge.fury.io\u002Fpy\u002Feinops)\n[![文档](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fdocumentation-link-blue.svg)](https:\u002F\u002Feinops.rocks\u002F)\n![支持的 Python 版本](https:\u002F\u002Fraw.githubusercontent.com\u002Farogozhnikov\u002Feinops\u002Fmain\u002Fdocs\u002Fresources\u002Fpython_badge.svg)\n\n\n灵活且强大的张量操作，让代码更易读、更可靠。\u003Cbr \u002F>\n支持 NumPy、PyTorch、JAX、MLX 等多种框架。\n\n## 最新更新：\n\n- [einops 演示环境](https:\u002F\u002Farogozhnikov.github.io\u002Fjupyterlite\u002Flab\u002Findex.html?download_github_folder=arogozhnikov\u002Feinops\u002Fdocs) 可以直接在浏览器中运行其中的 2 个示例笔记本\n- 0.8.2：新增 MLX 后端\n- 0.8.0：新增 Tinygrad 后端，并进行了一些小修复\n- 0.7.0：无需繁琐配置即可使用 `torch.compile`，支持 [Array API 标准](https:\u002F\u002Fdata-apis.org\u002Farray-api\u002Flatest\u002FAPI_specification\u002Findex.html)，以及其他改进\n- 10,000🎉：GitHub 报告称已有超过 1 万个项目在使用 einops\n- einops 0.6.1：新增 Paddle 后端\n- einops 0.6 引入了 [打包与解包](https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fblob\u002Fmain\u002Fdocs\u002F4-pack-and-unpack.ipynb)\n- einops 0.5：einsum 现已成为 einops 的一部分\n- [Einops 论文](https:\u002F\u002Fopenreview.net\u002Fpdf?id=oapKSVM2bcj) 被 ICLR 2022 接受为口头报告（确实值得一读）。演讲录像已[公开](https:\u002F\u002Ficlr.cc\u002Fvirtual\u002F2022\u002Foral\u002F6603)\n\n\n\u003Cdetails markdown=\"1\">\n\u003Csummary>往期更新\u003C\u002Fsummary>\n- 新增 Flax 和 OneFlow 后端\n- 支持 PyTorch 层的 `torch.jit.script`\n- 在 einops 中加入了功能强大的 EinMix。[Einmix 教程笔记本](https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fblob\u002Fmain\u002Fdocs\u002F3-einmix-layer.ipynb)\n\u003C\u002Fdetails>\n\n\u003C!--\u003Cdiv align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Farogozhnikov_einops_readme_b297cf6447f5.png\" \n  alt=\"einops 包标志\" width=\"250\" height=\"250\" \u002F>\n  \u003Cbr>\u003Cbr>\n\u003C\u002Fdiv> -->\n\n\n## 推文 \n\n> 如果你还需要理由来花时间学习 einsum 和 einops...\n[Tim Rocktäschel](https:\u002F\u002Ftwitter.com\u002F_rockt\u002Fstatus\u002F1230818967205425152)\n\n> 使用 PyTorch 和 einops 编写更好的代码 👌\n[Andrej Karpathy](https:\u002F\u002Ftwitter.com\u002Fkarpathy\u002Fstatus\u002F1290826075916779520)\n\n> einops 正在慢慢渗透到我代码的每一个角落。如果你经常需要处理高维张量，它可能会改变你的工作方式。\n[Nasim Rahaman](https:\u002F\u002Ftwitter.com\u002Fnasim_rahaman\u002Fstatus\u002F1216022614755463169)\n\n[更多评价](https:\u002F\u002Feinops.rocks\u002Fpages\u002Ftestimonials\u002F)\n\n\n## 目录\n\n- [安装](#Installation)\n- [文档](https:\u002F\u002Feinops.rocks\u002F)\n- [教程](#Tutorials)\n- [API 微参考](#API)\n- [为什么使用 einops](#Why-use-einops-notation)\n- [支持的框架](#Supported-frameworks)\n- [引用](#Citing)\n- [仓库](https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops) 和 [讨论区](https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fdiscussions)\n\n## 安装  \u003Ca name=\"Installation\">\u003C\u002Fa>\n\n非常简单：\n```bash\npip install einops\n```\n\n(`uv pip install einops` 也同样适用)\n\n## 教程 \u003Ca name=\"Tutorials\">\u003C\u002Fa>\n\n教程是了解 `einops` 实际应用的最佳方式\n\n- 第一部分：[einops 基础](https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fblob\u002Fmain\u002Fdocs\u002F1-einops-basics.ipynb)\n- 第二部分：[einops 用于深度学习](https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fblob\u002Fmain\u002Fdocs\u002F2-einops-for-deep-learning.ipynb)\n- 第三部分：[打包与解包](https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fblob\u002Fmain\u002Fdocs\u002F4-pack-and-unpack.ipynb)\n- 第四部分：[用 einops 改进 PyTorch 代码](http:\u002F\u002Feinops.rocks\u002Fpytorch-examples.html)\n\nKapil Sachdeva 录制了一个简短的 [einops 入门视频](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=xGy75Pjsqzo)。\n\n## API \u003Ca name=\"API\">\u003C\u002Fa>\n\n`einops` 拥有极简但功能强大的 API。\n\n提供了三项核心操作（[einops 教程](https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fblob\u002Fmain\u002Fdocs\u002F)展示了这些操作可以覆盖堆叠、重塑、转置、挤压\u002F扩展、重复、平铺、拼接、视图以及多种约简操作）：\n\n```python\nfrom einops import rearrange, reduce, repeat\n# 按照指定模式重新排列元素\noutput_tensor = rearrange(input_tensor, 't b c -> b c t')\n# 结合重新排列和约简操作\noutput_tensor = reduce(input_tensor, 'b c (h h2) (w w2) -> b h w c', 'mean', h2=2, w2=2)\n# 沿新轴复制\noutput_tensor = repeat(input_tensor, 'h w -> h w c', c=3)\n```\n\n后来又增加了 `pack` 和 `unpack` 函数（比传统的堆叠\u002F拆分\u002F拼接更优）：\n\n```python\nfrom einops import pack, unpack\n# pack 和 unpack 可以将多个张量可逆地“打包”成一个张量。\n# 被打包的张量可以具有不同的维度：\npacked, ps = pack([class_token_bc, image_tokens_bhwc, text_tokens_btc], 'b * c')\nclass_emb_bc, image_emb_bhwc, text_emb_btc = unpack(transformer(packed), ps, 'b * c')\n```\n\n最后，einops 还提供了支持多字母变量名的 einsum：\n\n```python\nfrom einops import einsum, pack, unpack\n# einsum 就像……einsum，是一种通用且灵活的点积运算，\n# 不过 1) 轴可以使用多字母名称 2) 模式放在最后 3) 支持多种框架\nC = einsum(A, B, 'b t1 head c, b t2 head c -> b head t1 t2')\n```\n\n### EinMix\n\n`EinMix` 是一种通用的线性层，非常适合 MLP Mixer 等架构。\n\n### 层\n\nEinops 提供了层（`einops` 为每个框架保留单独的版本），这些层反映了相应的函数：\n\n```python\nfrom einops.layers.torch      import Rearrange, Reduce\nfrom einops.layers.tensorflow import Rearrange, Reduce\nfrom einops.layers.flax       import Rearrange, Reduce\nfrom einops.layers.paddle     import Rearrange, Reduce\n```\n\n\u003Cdetails markdown=\"1\">\n\u003Csummary>在 PyTorch 模型中使用层的示例\u003C\u002Fsummary>\n此处以 PyTorch 为例，但其他框架中的代码几乎相同。\n\n```python \nfrom torch.nn import Sequential, Conv2d, MaxPool2d, Linear, ReLU\nfrom einops.layers.torch import Rearrange\n\nmodel = Sequential(\n    ...,\n    Conv2d(6, 16, kernel_size=5),\n    MaxPool2d(kernel_size=2),\n    # 无需编写 forward 方法即可完成展平\n    Rearrange('b c h w -> b (c h w)'),\n    Linear(16*5*5, 120),\n    ReLU(),\n    Linear(120, 10),\n)\n```\n\n不再需要手动展平！\n\n此外，PyTorch 的层是可脚本化和可编译的。操作可以被 `torch.compile` 编译，\n但由于 `torch.jit.script` 的限制，无法进行脚本化。\n\u003C\u002Fdetails>\n\n\n\n\n## 名称 \u003Ca name=\"Naming\">\u003C\u002Fa>\n\n`einops` 代表受爱因斯坦启发的操作记号法，\n尽管“爱因斯坦操作”听起来更吸引人且更容易记住。\n\n这种记号法大致受到爱因斯坦求和约定的启发（特别是 `numpy.einsum` 操作）。\n\n## 为什么使用 `einops` 记号法？！ \u003Ca name=\"Why-use-einops-notation\">\u003C\u002Fa>\n\n\n### 语义信息（明确期望）\n\n```python\ny = x.view(x.shape[0], -1)\ny = rearrange(x, 'b c h w -> b (c h w)')\n```\n虽然这两行代码在 *某些* 情境下执行相同的操作，\n但第二行提供了关于输入和输出的信息。换句话说，`einops` 关注接口：*输入和输出是什么*，而不是 *如何计算输出*。\n\n下一个操作看起来类似：\n\n```python\ny = rearrange(x, 'time c h w -> time (c h w)')\n```\n但它给读者一个提示：\n我们处理的不是独立的一批图像，\n而是一个序列（视频）。\n\n语义信息使代码更易于阅读和维护。\n\n### 方便的检查\n\n再看同一个例子：\n\n```python\ny = x.view(x.shape[0], -1) # x: (batch, 256, 19, 19)\ny = rearrange(x, 'b c h w -> b (c h w)')\n```\n第二行会检查输入是否具有四个维度，\n你还可以指定具体的维度。\n这与仅仅写形状注释不同，因为注释并不能防止错误，\n而且如果没有经过代码审查，很容易过时。\n```python\ny = x.view(x.shape[0], -1) # x: (batch, 256, 19, 19)\ny = rearrange(x, 'b c h w -> b (c h w)', c=256, h=19, w=19)\n```\n\n### 结果严格确定\n\n下面我们至少有两种方式来定义深度转空间操作：\n```python\n# 深度转空间\nrearrange(x, 'b c (h h2) (w w2) -> b (c h2 w2) h w', h2=2, w2=2)\nrearrange(x, 'b c (h h2) (w w2) -> b (h2 w2 c) h w', h2=2, w2=2)\n```\n实际上还有至少四种其他方式。那么框架到底使用哪一种呢？\n\n这些细节通常会被忽略，因为*通常*不会产生影响，\n但在某些情况下（例如在下一阶段使用分组卷积时）可能会有很大差异，\n而你希望在代码中明确指定这一点。\n\n\n### 统一性\n\n```python\nreduce(x, 'b c (x dx) -> b c x', 'max', dx=2)\nreduce(x, 'b c (x dx) (y dy) -> b c x y', 'max', dx=2, dy=3)\nreduce(x, 'b c (x dx) (y dy) (z dz) -> b c x y z', 'max', dx=2, dy=3, dz=4)\n```\n这些示例表明，我们不需要为 1D\u002F2D\u002F3D 池化分别定义不同的操作，\n它们都可以用统一的方式定义。\n\n空间转深度和深度转空间在许多框架中都有定义，那宽度转高度呢？如下所示：\n\n```python\nrearrange(x, 'b c h (w w2) -> b c (h w2) w', w2=2)\n```\n\n\n### 框架无关的行为\n\n即使是简单的函数，在不同框架中也有不同的定义：\n\n```python\ny = x.flatten() # 或 flatten(x)\n```\n\n假设 `x` 的形状是 `(3, 4, 5)`，那么 `y` 的形状将是……\n\n- NumPy、PyTorch、CuPy、Chainer、JAX：`(60,)`\n- Keras、TensorFlow Layers、Gluon：`(3, 20)`\n\n`einops` 在所有框架中都以相同的方式工作。\n\n\n### 框架术语的独立性\n\n例如，“tile”和“repeat”常常让人困惑。要沿宽度复制图像：\n```python\nnp.tile(image, (1, 2))    # 在 NumPy 中\nimage.repeat(1, 2)        # PyTorch 的 repeat 类似于 NumPy 的 tile\n```\n\n使用 `einops`，你就不需要去弄清楚是哪个轴被重复了：\n```python\nrepeat(image, 'h w -> h (tile w)', tile=2)  # 在 NumPy 中\nrepeat(image, 'h w -> h (tile w)', tile=2)  # 在 PyTorch 中\nrepeat(image, 'h w -> h (tile w)', tile=2)  # 在 TensorFlow 中\nrepeat(image, 'h w -> h (tile w)', tile=2)  # 在 JAX 中\nrepeat(image, 'h w -> h (tile w)', tile=2)  # 在 CuPy 中\n... (等等)\n```\n\n[用户评价](https:\u002F\u002Feinops.rocks\u002Fpages\u002Ftestimonials\u002F)提供了用户对同一问题的看法。\n\n\n## 支持的框架 \u003Ca name=\"Supported-frameworks\">\u003C\u002Fa>\n\nEinops 支持以下框架：\n\n- [NumPy](http:\u002F\u002Fwww.numpy.org\u002F)\n- [PyTorch](https:\u002F\u002Fpytorch.org\u002F)\n- [TensorFlow](https:\u002F\u002Fwww.tensorflow.org\u002F)\n- [JAX](https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fjax)\n- [CuPy](https:\u002F\u002Fgithub.com\u002Fcupy\u002Fcupy)\n- [Flax](https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fflax)（社区版）\n- [Paddle](https:\u002F\u002Fgithub.com\u002FPaddlePaddle\u002FPaddle)（社区版）\n- [OneFlow](https:\u002F\u002Fgithub.com\u002FOneflow-Inc\u002Foneflow)（社区版）\n- [TinyGrad](https:\u002F\u002Fgithub.com\u002Ftinygrad\u002Ftinygrad)（社区版）\n- [PyTensor](https:\u002F\u002Fgithub.com\u002Fpymc-devs\u002Fpytensor)（社区版）\n\n\n\n```python\nfrom einops import rearrange  \n=> from einops.array_api import rearrange\n```\n\n但实际上更好：`einops` 可以与任何支持\n[Python 数组 API 标准](https:\u002F\u002Fdata-apis.org\u002Farray-api\u002Flatest\u002FAPI_specification\u002Findex.html) 的框架一起使用，\n例如：\n\n- NumPy ≥ 2.0\n- [MLX](https:\u002F\u002Fgithub.com\u002Fml-explore\u002Fmlx)  # 是的，`einops` 可以与苹果的框架一起使用\n- [PyData\u002FSparse](https:\u002F\u002Fgithub.com\u002Fpydata\u002Fsparse) ≥ 0.15 # 并且支持稀疏张量\n- [Cubed](https:\u002F\u002Fgithub.com\u002Fcubed-dev\u002Fcubed) # 还支持分布式张量\n- [Quantco\u002Fndonnx](https:\u002F\u002Fgithub.com\u002FQuantco\u002Fndonnx)\n- JAX\n- CuPy\n- Dask 也可以通过 [array-api-compat](https:\u002F\u002Fgithub.com\u002Fdata-apis\u002Farray-api-compat) 来支持\n\n\n## 开发\n\n提供了 Devcontainer 环境，可以在本地、服务器上或 GitHub Codespaces 中使用。\n要在 VS Code 中使用 Devcontainer，只需克隆仓库并点击“在 Devcontainer 中重新打开”。\n\n从 `einops` 0.8.1 开始，`einops` 将测试作为包的一部分分发。\n\n```bash\n# pip install einops pytest\npython -m einops.tests.run_tests numpy pytorch jax --pip-install\n```\n\n`numpy pytorch jax` 只是一个 _示例_，可以提供任何可测试框架的子集。\n每个框架都会与 NumPy 进行对比测试，因此这是测试的前提条件。\n\n指定 `--pip-install` 会在当前虚拟环境中安装依赖项，\n如果本地已安装依赖，则应省略该选项。\n\n构建和测试文档：\n\n```bash\nhatch run docs:serve  # 在 http:\u002F\u002Flocalhost:8000\u002F 上提供服务\n```\n\n## 引用 einops \u003Ca name=\"Citing\">\u003C\u002Fa>\n\n请使用以下 BibTeX 条目：\n\n```text\n@inproceedings{\n    rogozhnikov2022einops,\n    title={Einops: 基于爱因斯坦求和约定的清晰可靠的张量操作},\n    author={Alex Rogozhnikov},\n    booktitle={国际表示学习会议},\n    year={2022},\n    url={https:\u002F\u002Fopenreview.net\u002Fforum?id=oapKSVM2bcj}\n}\n```\n\n\n## 支持的 Python 版本\n\n`einops` 支持 Python 3.10 及更高版本。","# Einops 快速上手指南\n\nEinops 是一个灵活且强大的张量操作库，旨在编写可读性高、可靠性强的代码。它支持 NumPy、PyTorch、JAX、TensorFlow、MLX 等多种主流深度学习框架，通过统一的符号表示法简化张量的重塑、转置、重复和归约等操作。\n\n## 环境准备\n\n- **操作系统**：Linux, macOS, Windows\n- **Python 版本**：支持 Python 3.7+（推荐最新稳定版）\n- **前置依赖**：无需特殊系统依赖，只需安装目标深度学习框架（如 `torch`, `tensorflow`, `jax` 等）之一即可。\n\n## 安装步骤\n\n使用 pip 进行安装（推荐使用国内镜像源加速）：\n\n```bash\npip install einops -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n```\n\n或者使用 `uv` 工具安装：\n\n```bash\nuv pip install einops\n```\n\n## 基本使用\n\nEinops 的核心 API 非常简洁，主要包含 `rearrange`（重排）、`reduce`（归约）和 `repeat`（重复）三个函数。\n\n### 1. 导入库\n\n```python\nfrom einops import rearrange, reduce, repeat\n```\n\n### 2. 张量重排 (Rearrange)\n替代繁琐的 `view`, `transpose`, `permute` 等操作，直观定义输入输出维度。\n\n```python\n# 将形状为 (t, b, c) 的张量转换为 (b, c, t)\n# 模式字符串 't b c -> b c t' 清晰表达了维度变换逻辑\noutput_tensor = rearrange(input_tensor, 't b c -> b c t')\n```\n\n### 3. 组合重排与归约 (Reduce)\n在一个操作中完成维度调整和数据聚合（如均值池化）。\n\n```python\n# 对高度和宽度进行 2x2 的平均池化\n# h2=2, w2=2 指定了池化核的大小\noutput_tensor = reduce(input_tensor, 'b c (h h2) (w w2) -> b h w c', 'mean', h2=2, w2=2)\n```\n\n### 4. 维度复制 (Repeat)\n沿新轴复制数据，替代各框架中不一致的 `tile` 或 `repeat` 用法。\n\n```python\n# 将灰度图 (h, w) 复制通道维变为 RGB 格式 (h, w, 3)\noutput_tensor = repeat(input_tensor, 'h w -> h w c', c=3)\n```\n\n### 5. 在 PyTorch 模型中使用\nEinops 提供了可直接嵌入神经网络模型的 Layer 封装。\n\n```python\nfrom torch.nn import Sequential, Conv2d, Linear, ReLU, MaxPool2d\nfrom einops.layers.torch import Rearrange\n\nmodel = Sequential(\n    Conv2d(6, 16, kernel_size=5),\n    MaxPool2d(kernel_size=2),\n    # 无需手动编写 forward 函数进行 flatten，直接描述维度变化\n    Rearrange('b c h w -> b (c h w)'),\n    Linear(16*5*5, 120),\n    ReLU(),\n    Linear(120, 10),\n)\n```","一位计算机视觉工程师正在开发基于 Vision Transformer (ViT) 的图像分类模型，需要频繁处理图像块（Patches）与序列维度之间的复杂张量变换。\n\n### 没有 einops 时\n- **代码可读性差**：依赖晦涩的 `view`、`transpose` 和 `permute` 组合，其他开发者难以一眼看出张量形状的具体变化逻辑。\n- **维护成本高昂**：硬编码的维度索引（如 `x.shape[1]`）在模型结构调整时极易出错，导致“维度不匹配”的运行时崩溃。\n- **框架迁移困难**：从 PyTorch 迁移到 JAX 或 TensorFlow 时，必须重写所有底层张量操作代码，因为不同框架的 API 存在差异。\n- **调试效率低下**：需要在代码中插入大量 `print(tensor.shape)` 来追踪中间状态，才能定位数据流向错误。\n\n### 使用 einops 后\n- **逻辑声明式表达**：通过 `rearrange(x, 'b c (h p1) (w p2) -> b (h w) (p1 p2 c)', ...)` 这种类似数学公式的语法，直观描述维度拆分与合并，代码即文档。\n- **鲁棒性显著增强**：不再依赖具体的数字索引，只要维度名称匹配，即使批量大小或图像分辨率变化，代码也能自动适应，减少报错。\n- **无缝框架切换**：同一套 einops 代码可直接运行于 PyTorch、JAX、TensorFlow 等多种后端，无需修改任何算子调用，极大降低迁移门槛。\n- **开发心流顺畅**：开发者只需关注数据逻辑而非底层内存布局，消除了繁琐的形状计算，将更多精力投入模型架构创新。\n\neinops 将易错的张量“杂技”转化为清晰可靠的声明式代码，是深度学习工程师提升研发效率与代码质量的必备利器。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Farogozhnikov_einops_b297cf64.png","arogozhnikov","Alex Rogozhnikov","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Farogozhnikov_b57d4728.jpg","ML + Science, einops, scientific tools, protein design",null,"San Francisco","https:\u002F\u002Farogozhnikov.github.io","https:\u002F\u002Fgithub.com\u002Farogozhnikov",[82,86,90,94],{"name":83,"color":84,"percentage":85},"Python","#3572A5",68.5,{"name":87,"color":88,"percentage":89},"Jupyter Notebook","#DA5B0B",29.9,{"name":91,"color":92,"percentage":93},"CSS","#663399",1.5,{"name":95,"color":96,"percentage":97},"Dockerfile","#384d54",0.1,9452,397,"2026-04-08T15:02:57","MIT",1,"","未说明",{"notes":106,"python":107,"dependencies":108},"einops 是一个纯 Python 库，不强制依赖特定的深度学习框架，而是作为通用层支持多种后端（如 PyTorch, TensorFlow, JAX, NumPy 等）。它兼容遵循 Python Array API 标准的任何框架。安装仅需执行 'pip install einops'，无特殊硬件或系统要求。","3.8+",[109,110,111,112,113,114,115,116,117,118],"numpy","pytorch","tensorflow","jax","cupy","flax","paddle","oneflow","tinygrad","mlx",[14],[121,110,111,109,113,122,112,64,118],"deep-learning","tensor","2026-03-27T02:49:30.150509","2026-04-09T09:38:48.493087",[126,131,136,141,146,151],{"id":127,"question_zh":128,"answer_zh":129,"source_url":130},25874,"einops 如何与 torch.compile 配合使用以获得最佳性能？","从 einops 0.7.0rc1 版本开始，支持操作的自动注册，可以直接与 torch.compile 配合使用。请安装该版本：\npip install einops==0.7.0rc1\n在此版本之前，可能需要手动注册操作或等待 PyTorch 端的补丁合并。新版本会自动在 torch 后端构造函数中运行 allow_ops_in_compiled_graph。","https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fissues\u002F250",{"id":132,"question_zh":133,"answer_zh":134,"source_url":135},25875,"einops 是否支持类似 numpy.einsum 的功能，但可以使用描述性的维度名称？","是的，einops 自 0.5.0 版本起已原生支持 einops.einsum。它允许使用描述性的维度名称（如 'b h w c'），提供了比标准 einsum 更好的可读性。参数顺序采用“模式在最后”的设计，以便更容易追踪数据流。","https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fissues\u002F73",{"id":137,"question_zh":138,"answer_zh":139,"source_url":140},25876,"如何在 rearrange 中引入新的命名轴（例如将向量扩展以匹配其他张量）？","rearrange 操作默认严格要求两侧的标识符必须匹配，不支持直接在模式中引入未出现在输入侧的新命名轴（如 'b -> a b c'）。如果需要引入新的命名轴（通常用于广播），应使用 repeat 函数。例如：repeat(x, 'b -> a b c', a=1, c=1)。","https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fissues\u002F29",{"id":142,"question_zh":143,"answer_zh":144,"source_url":145},25877,"einops 的维度名称是否支持大写字母或下划线？","自 einops 0.3 版本起，维度名称已支持大写字母。关于下划线 '_'：在 rearrange、reduce 和 repeat 操作中，'_' 是保留字符，不允许作为轴名称使用；但在 parse_shape 函数中，'_' 是允许的，表示跳过该轴。","https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fissues\u002F28",{"id":147,"question_zh":148,"answer_zh":149,"source_url":150},25878,"在使用 torch.jit.trace 追踪包含 rearrange 的模块时出现 floor_divide 警告，该如何解决？","该警告是由于 PyTorch 内部实现使用了已弃用的 floor_divide。虽然警告本身通常不影响功能（除非涉及负数取整的特殊情况），但可以通过更新 einops 到最新版本来缓解，因为维护者会针对 PyTorch 的新特性（如 rounding_mode 参数）进行适配。如果警告干扰日志，可在代码中临时过滤该特定警告，或确保使用较新的 PyTorch 和 einops 版本以保持兼容。","https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fissues\u002F130",{"id":152,"question_zh":153,"answer_zh":154,"source_url":155},25879,"有没有在线的交互式工具可以学习或测试 einops 的操作？","有的，项目提供了基于 JupyterLite 的交互式 Playground。你可以直接访问文档中的 Notebook 链接进行尝试。这些 Notebook 托管在 GitHub 上，并通过 nbviewer 或 JupyterLite 加载，支持基本的 rearrange、pack\u002Funpack 等操作演示，无需本地安装即可在浏览器中运行和重置实验。","https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fissues\u002F340",[157,162,167,172,177,182,187,192,197,202,207,212,217,222,227,232],{"id":158,"version":159,"summary_zh":160,"released_at":161},163193,"v0.8.2","\r\n\r\n- torch.compile：此前我们依赖于在 torch.compile 中注册 einops。该注册由 torch 调用。现在，随着 torch >= 2.8，`torch.compile` 引擎无需额外的提示或注册即可编译 einops 操作。\n- 对于 MLX，推荐的后端仍然是 `einops.array_api.\u003Coperation>`，但由于社区多次要求支持 `einops.einsum`，因此 einops 现已提供 MLX 后端，这意味着 `einops.\u003Coperation>` 也可以与 MLX 配合使用。\n- 文档的细微改进，以及对若干相关项目的提及。\r\n\r\n\r\n\r\n\r\n\r\n\r\n## 变更内容\r\n* 更新 README.md，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F366 中完成\n* 更新代码库，引入一致性检查，并更新 EinMix 教程，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F374 中完成\n* 更新测试中的 Python 版本，将最低支持版本改为 3.9，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F364 中完成\n* 通过数组 API 提及 cubed 作为另一个后端，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F375 中完成\n* 扩展针对 torch.compile 的测试，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F382 中完成\n* 在 docs_src\u002Fpages\u002Fprojects.md 中添加 einops.jl 和 R 语言版 einops，由 @Qile0317 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F383 中完成\n* 提及 ein color 和 AlphaFold3，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F389 中完成\n* 增加了一些编译测试，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F390 中完成\n* 修复 #391（多线程初始化中的冲突），由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F392 中完成\n* 关闭调试导入功能，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F393 中完成\n* 如果 torch >= 2.8，则跳过 `allow_in_graph`，由 @guilhermeleobas 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F394 中完成\n* 添加 mlx 后端，由 @ifsheldon 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F376 中完成\n* 更新测试，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F395 中完成\n\n## 新贡献者\n* @Qile0317 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F383 中完成了首次贡献\n* @guilhermeleobas 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F394 中完成了首次贡献\n* @ifsheldon 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F376 中完成了首次贡献\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fcompare\u002Fv0.8.1...v0.8.2","2026-01-26T04:12:47",{"id":163,"version":164,"summary_zh":165,"released_at":166},163194,"v0.8.1","## 变更内容\n\n简而言之：\n\n- 在 EinMix 中添加了省略号功能\n- 测试代码移至包内\n- 提供了开发容器\n- 添加了 PyTensor 后端\n- 一些小改进：增加了引用信息、更新了文档、修复了损坏的链接\n- 这些更改并未涉及 einops 核心代码的修改，但如今更多库支持数组 API，einops 也能够在其上运行\n\n\n## 拉取请求：\n\n* 更新 README.md，由 @project-delphi 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F316 中提交\n* 针对 NumPy 2.0 的测试变更及 NumPy 回归问题修复，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F325 中提交\n* 来自 @pzread 的 PR：修复 Tinygrad 的 concat 操作，并调整格式以解决 CI 错误，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F329 中合并\n* 添加开发容器和 Dockerfile，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F330 中提交\n* 删除 experimental\u002Findexing 目录，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F333 中提交\n* 在 CI 和 pre-commit 中使用相同版本的 ruff 工具，并重新格式化笔记本文件，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F336 中提交\n* 删除 Chainer 后端，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F335 中提交\n* 提及对 CuPy、pydata\u002Fsparse、NDonnx 等库的支持，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F337 中提交\n* 将测试代码移入源码树，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F338 中提交\n* 更新文档，说明测试和开发容器方面的变更，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F339 中提交\n* 实现 MkDocs 自动部署并更新 MkDocs 依赖项，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F341 中提交\n* 在 einops 层示例中添加字典语法，由 @eadadi 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F342 中提交\n* 为 einops 添加 CITATION.cff 文件，由 @luke-carlson 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F345 中提交\n* 提及 CuPy 和 JAX 现已支持数组 API，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F348 中提交\n* 修复 `master` 切换到 `main` 分支后文档中的链接错误，由 @VladKha 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F349 中提交\n* [Paddle] 更新 _backends.py 以支持 pir.Value，由 @HydrogenSulfate 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F353 中提交\n* 更新 einops.reduce 的文档字符串，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F358 中提交\n* 添加关于轴名称的注释，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F359 中提交\n* 为 einmix 添加省略号支持，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F360 中提交\n* 添加 PyTensor 后端，由 @ricardoV94 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F362 中提交\n* 重命名 input_dict 参数并完善文档说明，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F363 中提交\n\n## 新贡献者\n* @project-delphi 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F316 中完成了首次贡献\n* @eadadi 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F342 中完成了首次贡献\n* @luke-carlson 在 https:\u002F\u002Fgithub.com\u002Farogo","2025-02-09T03:16:30",{"id":168,"version":169,"summary_zh":170,"released_at":171},163195,"v0.8.0","## 简述\r\n\r\n- 添加了 tinygrad 后端\r\n- 解决了与文档字符串相关的 Python 3.11 警告\r\n- 移除了 unpack 中的图断点\r\n- **破坏性变更**：更新了 TensorFlow 层以遵循新规范，新层兼容 TensorFlow 2.16，但不兼容旧版本（显然无法在 TensorFlow 2.13 上运行）\r\n\r\n## 变更内容\r\n* 修复 einsum 文档字符串中的无效转义序列，由 @atwam 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F298 中完成\r\n* 增加对 tinygrad 的支持，由 @blueridanus 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F297 中完成\r\n* 在 unpack 中将布尔值强制转换为整数，由 @drubinstein 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F287 中完成\r\n* 从测试中移除 OneFlow，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F289 中完成\r\n* 测试：修复 PyTorch 安装以强制使用 CPU，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F288 中完成\r\n* 允许 parse_shape 中使用匿名轴，修复 #302，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F303 中完成\r\n* 代码库规范 + 更新 TensorFlow 层，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F318 中完成\r\n* 更新 GitHub Actions，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F319 中完成\r\n\r\n## 新贡献者\r\n* @drubinstein 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F287 中完成了首次贡献\r\n* @atwam 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F298 中完成了首次贡献\r\n* @blueridanus 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F297 中完成了首次贡献\r\n\r\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fcompare\u002Fv0.7.0...v0.8.0","2024-04-28T04:07:18",{"id":173,"version":174,"summary_zh":175,"released_at":176},163196,"v0.7.0","重大变更：\n\n- `torch.compile` 现已开箱即用，操作的注册会自动完成。\n- JAX 的分布式数组现在可以使用省略号，并且总体而言，省略号的处理方式现在会保留轴的身份。这涉及到对 einops 内部机制的调整。\n- 数组 API：遵循该标准的任何框架都可以使用 `einops` 操作（参见 `einops.array_api`）。\n- Python 3.7 已停止支持。再见了，你当年真的很棒。\n- 如先前宣布，已移除 Gluon 支持。\n- `reduce`、`repeat` 和 `rearrange` 现在都接受列表作为输入。\n\n## PR 列表\n* 保留轴身份并移除 Python 3.7 支持，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F255 中完成。\n* 支持数组 API，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F261 中完成。\n* 添加基于类型的缓存功能，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F262 中完成。\n* 在 `rearrange`、`reduce` 和 `repeat` 中统一支持列表输入，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F263 中完成。\n* 移除 Gluon 支持，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F264 中完成。\n* 在 torchdynamo 中自动注册 PyTorch 操作，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F265 中完成。\n* 发布 0.7.0rc1 版本，并在 README 中突出显示变更内容，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F266 中完成。\n* 覆盖 `torch.compile` 中的动态形状，并在形状不可缓存时引入回退机制，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F275 中完成。\n* 提升版本号，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F276 中完成。\n* 修复 #279 问题并更新描述，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F281 中完成。\n* 在 `einops.reduce` 中添加对任意\u002F所有约简的支持，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F282 中完成。\n* 维护工作：缓存 pip 依赖项，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F283 中完成。\n* 维护工作：更新 GitHub Actions 的版本，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F285 中完成。\n\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fcompare\u002Fv0.6.1...v0.7.0","2023-10-01T01:13:00",{"id":178,"version":179,"summary_zh":180,"released_at":181},163197,"v0.7.0rc2","## 变更内容\n* 在 `torch.compile` 中支持覆盖动态形状，并在形状不可缓存时引入回退机制，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F275 中实现\n* 由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F276 中更新版本号\n\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fcompare\u002Fv0.7.0rc1...v0.7.0rc2","2023-08-14T05:41:41",{"id":183,"version":184,"summary_zh":185,"released_at":186},163198,"v0.7.0rc1","重大变更：\n\n- `torch.compile` 现已开箱即用，操作的注册会自动完成。\n- JAX 的分布式数组现在可以使用省略号，且总体而言，省略号的处理方式会保留轴的身份。这涉及到对 einops 内部机制的调整。\n- 数组 API：遵循该标准的任何框架都可以使用 `einops` 操作（参见 `einops.array_api`）。\n- Python 3.7 已停止支持。再见了，你当年真的很棒。\n- 如先前宣布，已移除 Gluon 支持。\n- `reduce`、`repeat` 和 `rearrange` 现在都接受列表作为输入。\n\n## 变更内容\n* 支持数组 API，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F261 中实现。\n* 添加基于类型的缓存功能，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F262 中实现。\n* 统一支持 `rearrange`、`reduce` 和 `repeat` 中的列表输入，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F263 中实现。\n* 移除 Gluon 支持，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F264 中实现。\n* 在 torchdynamo 中自动注册 PyTorch 操作，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F265 中实现。\n* 发布 0.7.0rc1 版本，并在 README 中突出显示变更内容，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F266 中实现。\n* 保留轴身份并移除对 Python 3.7 的支持，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F255 中实现。\n\n\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fcompare\u002Fv0.6.1...v0.7.0rc1","2023-07-08T02:54:04",{"id":188,"version":189,"summary_zh":190,"released_at":191},163199,"v0.6.2rc0","发布预发布版本，以便公众测试新的缓存逻辑（模式分析现在依赖于输入的维度，以保留轴的身份）。\n\n## 变更内容\n* 保留轴的身份 + 移除对 Python 3.7 的支持，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F255 中完成。\n\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fcompare\u002Fv0.6.1...v0.6.2rc0","2023-07-05T08:17:56",{"id":193,"version":194,"summary_zh":195,"released_at":196},163200,"v0.6.1","- einops 的层与 torch.compile 完美配合\n- einops 操作需要注册：在调用 `torch.compile` 之前，请先运行 `einops._torch_specific.allow_ops_in_compiled_graph()`\n- 现已支持 PaddlePaddle（感谢 @zhouwei25）\n- 如先前宣布，已停止对 MXNet 的支持\n\n## 变更内容\n* @zhouwei25 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F242 和 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F245 中为 einops 添加了 PaddlePaddle 后端\n* @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F251 中添加了 `allow_ops_in_compiled_graph`，以支持 torch.compile\n* 将 `torch.concat` 替换为 `torch.cat`，以便在 torch \u003C 1.10 的版本中支持打包操作，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F238 中完成\n* 杂项工作：@arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F246 中改进了文档和测试\n* @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F231 中移除了对 MXNet 的支持\n\n\n## 新贡献者\n* @zhouwei25 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F242 中完成了首次贡献\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fcompare\u002Fv0.6.0...v0.6.1","2023-04-19T04:13:12",{"id":198,"version":199,"summary_zh":200,"released_at":201},163201,"v0.6.0","## 变更内容\n\n* @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F222 中引入了 einops.pack 和 einops.unpack。\n* @EPronovost 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F217 中更新了示例，使其与描述一致。\n* @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F221 中改进了类型提示。\n* 对 pack\u002Funpack 的美化：文档和注释，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F223 中完成。\n* 为 0.6.0 版本发布做准备，由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F224 中完成。\n\n## 新贡献者\n* @EPronovost 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F217 中做出了他们的首次贡献。\n\n## 公告\n\n逐步停止对实验性 MXNet 支持：由于需求不足且该包已过时，存在大量弃用内容，并且对边缘情况的支持较差。0.6.0 将是最后一个包含 MXNet 后端的版本。\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fcompare\u002Fv0.5.0...v0.6.0","2022-11-09T20:32:56",{"id":203,"version":204,"summary_zh":205,"released_at":206},163202,"v0.5.0","## 变更内容\n* 由 @MilesCranmer 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F197 中创建了 einsum 操作\n* 由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F214 中添加了 Flax 层\n* 由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F181 中添加了 OneFlow 后端\n* 由 @rentainhe 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F180 中添加了 OneFlow 后端\n* 由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F196 中修复了错误的错误信息\n* 由 @maxeonyx 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F201 中澄清了关于 EinMix 默认偏置的文档说明\n* 由 @cs-mshah 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F205 中修正了拼写错误：einsops -> einops\n* 由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F209 中为 bfloat16 添加了均值归约，并修复了 #206 问题\n* 由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F211 中添加了 py.typed（遵循 PEP 561）\n* 由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F212 中删除了 TensorFlow 特有的 README 文件\n* 由 @arogozhnikov 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F213 中采用了 pypa\u002Fhatch\n\n## 新贡献者\n* @rentainhe 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F180 中做出了首次贡献\n* @MilesCranmer 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F197 中做出了首次贡献\n* @maxeonyx 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F201 中做出了首次贡献\n* @cs-mshah 在 https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F205 中做出了首次贡献\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fcompare\u002Fv0.4.1...v0.5.0","2022-10-03T06:38:37",{"id":208,"version":209,"summary_zh":210,"released_at":211},163203,"v0.4.1","## What's Changed\r\n* fix numpy dependency problem by @lucidrains in https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F176\r\n\r\n## New Contributors\r\n* @lucidrains made their first contribution in https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F176\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fcompare\u002Fv0.4.0...v0.4.1","2022-03-04T09:31:30",{"id":213,"version":214,"summary_zh":215,"released_at":216},163204,"v0.4.0","## Main Changes\r\n\r\n- torch.jit.script is supported (in addition to previous torch.jit.trace)\r\n- EinMix (swiss-knife for next-gen MLPs) is added. A much-improved einsum\u002Flinear layer is now available.\r\n- einops.repeat in torch does not create copy when possible\r\n\r\n## Detailed PRs\r\n\r\n* Update documentation by @arogozhnikov in https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F137\r\n* Multiple updates in docs, add Rearrange layer to torch test  by @arogozhnikov in https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F138\r\n* Add support for torch scripting of einops layers by @arogozhnikov in https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F139\r\n* Introduce EinMix - swiss-knife for next-gen MLPs by @arogozhnikov in https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F142\r\n* Docs improvements: wording, visual style, EinMix by @arogozhnikov in https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F143\r\n* Move docs to a separate folder by @arogozhnikov in https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F144\r\n* Type hinting + add testing for EinMix composition\u002Fdecomposition by @arogozhnikov in https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F154\r\n* Reject repeated axes in parse_shape by @dmitriy-serdyuk in https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F159\r\n* Enable ellipsis in patterns for parse_shape. by @dmitriy-serdyuk in https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F162\r\n\r\n## New Contributors\r\n* @dmitriy-serdyuk made their first contribution in https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fpull\u002F159\r\n\r\n**Full Changelog**: https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fcompare\u002Fv0.3.2...v0.4.0","2022-01-18T07:30:54",{"id":218,"version":219,"summary_zh":220,"released_at":221},163205,"v0.3.2","- documentation and domain (#75, #76, #77, #79, #81), thanks to @cgarciae \r\n- typos and spellcheck (thank @ollema and @GarrettMooney )\r\n- moved away from keras to tf.keras\r\n- adjustments to tutorials and testing\r\n- other minor improvements","2021-08-31T22:49:08",{"id":223,"version":224,"summary_zh":225,"released_at":226},163206,"v0.3","- new operation: `repeat` (includes repeat\u002Ftiling logic, copying along a new dimension)\r\n- anonymous axes (specified by their length not name) are allowed:\r\n```python\r\ngrayscale = reduce(image, 'h w 3 -> h w', 'mean')\r\nimage_with_identical_channels = repeat(grayscale, 'h w -> h w 3')\r\n```\r\n- 1 can be used to refer to all dimensions of length 1\r\n- reduced restrictions on axes names: almost any python identified can be an axis name now\r\n- reduction can be provided with callable not string\r\n- tutorials were slightly updated to include these changes\r\n- code in kernel undergone refactoring, and now more documented\r\n- support: `keras` layers are deprecated in favor of `tf.keras` layers\r\n- experimental layer introduced: WeightedEinsum (RFC: #71 )","2020-09-08T08:33:29",{"id":228,"version":229,"summary_zh":230,"released_at":231},163207,"v0.2","- experimental support for Jax framework was added\r\n- testing code was rewritten and updated to work \r\n- tf2 always worked with einops, but tests had to be updated. So, tests are updated for tf2\r\n-  tf readme, minor additions, comments, etc. \r\n\r\nThanks to [contributors](https:\u002F\u002Fgithub.com\u002Farogozhnikov\u002Feinops\u002Fgraphs\u002Fcontributors)","2020-02-15T11:09:54",{"id":233,"version":234,"summary_zh":235,"released_at":236},163208,"v0.1","This release introduces einops, as well as its notion.\r\n\r\nInitial release API: \r\nOperations (ops)\r\n- `einops.rearrange` and `einops.reduce`\r\n\r\nAuxiliary\r\n\r\n- `einops.asnumpy` and  `einops.parse_shape`\r\n\r\nLayers (for chainer, gluon, keras and torch)\r\n\r\n- `Rearrange` and  `Reduce`\r\n\r\nSupported frameworks:\r\n\r\n- numpy\r\n- pytorch\r\n- tensorflow eager\r\n- cupy\r\n- chainer\r\n- gluon\r\n- tensorflow\r\n- mxnet (experimental)\r\n- and keras (experimental)\r\n\r\n","2018-11-01T00:58:32"]