Skip to content

wGreymon/wGCompiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wGCompiler

wGCompiler 的长期愿景是完成一个相对成熟(尽量🫥🫥)的 AI Compiler,目标是在不同芯片平台上对神经网络模型做贴合硬件特性的针对性优化,尽可能榨干硬件、把模型性能拉到更高。

当前阶段搭建了初步的框架,完成了memory、operator、graph层级,它更接近一个 demo 推理 runtime:先构建由 Tensor 和 Operator 组成的 Graph,再做形状推导、内存分配和简单图优化,最后由 CPU Runtime 调度 kernel 执行。后续会在这个骨架上继续补图优化、算子融合、内存复用、kernel 选择和面向不同硬件后端的优化能力。

长期方向

  • 支持更多模型图优化规则,让图结构更适合执行后端。
  • 针对不同芯片平台选择或生成更合适的 kernel。
  • 在内存规划、算子融合和布局转换上减少额外开销。
  • 逐步从 naive runtime 走向可扩展的 AI compiler 原型。

快速验证

构建项目:

make build

开发 Roadmap

状态说明:

  • ✅ 已具备
  • △ 部分具备,仍需补齐
  • ❌ 尚未开始或当前未落地
Topic Priority Status Notes
Transpose shape inference P0 根据 permute 重排输入维度
Clip shape inference P0 输出 shape 与输入一致
Cast shape / dtype inference P0 shape 不变,dtype 由 getOutputDataType() 决定
Concat shape inference P0 concat 轴累加,其余轴保持一致
Bidirectional broadcasting P0 从尾部维度对齐,支持标量和前导维广播
Matmul shape inference P0 处理 transAtransBm/n/k 和 batch broadcast
Tensor / Storage / Allocator P0 维护 free block,支持复用、释放和相邻 block 合并
Graph memory planning P0 按拓扑序分析 Tensor 生命周期,并绑定 data blob
Local graph optimization P1 删除冗余 transpose,并将可融合 transpose 合入 matmul 属性

参考规则

  • Transpose / Clip / Cast / Concat 形状规则参考 ONNX 对应算子定义。
  • 广播规则参考 ONNX Broadcasting。
  • Matmul 按最后两维做矩阵乘,前导 batch 维使用双向广播。
  • Runtime 当前只实现 Native CPU 路径,kernel 通过 (Device, OpType) 在 registry 中查找。

About

AI Compiler(naive😳😳😳)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages