当前位置: 首页 > news >正文

0824 MLIR和AST相关资料

  • 简单直观的理解:【编译原理:构建抽象语法树】
    编译原理:构建抽象语法树_哔哩哔哩_bilibili
  • 程序转为AST可视化:https://astexplorer.net/
  • MLIR的博客:https://www.cnblogs.com/YuanZiming/p/18956253
  • 学习MLIR的仓库:https://github.com/KEKE046/mlir-tutorial
  • for循环:https://blog.csdn.net/ReadyShowShow/article/details/137275857
  • if判断

DIST-IR中有用的测试用例

test/test_sequential_executor.py中的两个元素加法

test/test_simulator.py中的两个连续的矩阵乘法_test_data_parallel

test/test_pytorch_backend.py中的Send函数测试:test_send_recv

test/test_prettyprint.py中的两个连续的矩阵乘法:IR

tensor乘法simulator.py

在这里插入图片描述
完成图的构建,在这里采用了手写中间表示的方式
在这里插入图片描述
FunctionMaker中包含四个重要函数

  • add_op:参数为:操作码、输入、属性、子函数
  • add_input_value:添加输入值
  • set_outputs:设置元组输出
  • finalize:根据上面的参数构造Function

IR的格式

大萨

simulator的实现

IR表示SimulatorAbstractInterpreterCostModelFunctionSimulatorState调用simulate初始化state,分配input的设备、内存调用interpret(function, inputs, state)按拓扑序遍历ops从env获取输入值执行OP逻辑得到output值type、deviceloop[处理每个OP]返回更新后的state遍历所有ops从state.env获取OP的输入/输出值调用dispatch获取OP在设备上的costs返回costs调用_simulate_op更新状态同步设备时间戳记录轨迹trace更新设备timestamps和live_memoryloop[计算每个OP的成本与仿真]计算峰值内存set_peak_memory返回仿真结果(延迟、吞吐量、轨迹文件)IR表示SimulatorAbstractInterpreterCostModelFunctionSimulatorState

类型

Function = {# Invariant: ops are in topological orderops: List[Op]inputs: List[Value]outputs: List[Value]
}Device = {device_id: Int# Unique device IDdevice_type: String# Device type (e.g. "gpu")
}Op = {name: String# Do we need this to be unique in a function? Across all functions?op_type: OpType# The type of operatorin_edges: List[Value]# Pointer to a Value object either in Function.inputs or another Op.out_edgesout_edges: List[Value]# To support ops that have more than one outputattributes: Dict[String, Any]# Constant data for ops, e.g. stride of convolution or devices to scattersubfunctions: List[Function]
}OpType = | MatMul | Add | Relu | ...| MatMulGrad | ReluGrad | ...| N11Loss | SGDOptimizer | ...| Pmap | AllReduce | ...Value = {name: String# Again, does it need to be unique in a function?type: Typedevice: DeviceID# Which device this value lives on# TODO pointer to source op that generated this value?
}Type =| Tensor{shape: Optional[Shape], dtype: Type, device: Device}| Float | Int | ...| TupleType{elems: List[Type]}Topology = {devices: List[Device]# The list of all devices in the topology.bandwidths: Dict[Device, Dict[Device, Float]]# The bandwidth between each device.
}

dispatch是如何绑定的

更新字典的函数
在这里插入图片描述

  • 操作码类型推断:
    在这里插入图片描述

  • 混合输入的操作码类型推断:
    在这里插入图片描述

  • 实际操作码计算
    在这里插入图片描述

  • 通信类型操作码:
    在这里插入图片描述

http://www.dtcms.com/a/348904.html

相关文章:

  • 复杂工业场景识别率↑18.3%!陌讯多模态OCR算法实战解析
  • 虚幻引擎5(UE5)Android端游戏开发全流程指南:从环境配置到项目发布
  • Qt工具栏中图标槽函数没有响应的问题分析
  • 【JVM内存结构系列】三、堆内存深度解析:Java对象的“生存主场”
  • 【数据分享】地级市能源利用效率(超效率SBM、超效率CCR)(2006-2023)
  • Vue中 this.$emit() 方法详解, 帮助子组件向父组件传递事件
  • 纯血鸿蒙下的webdav库
  • vue中 computed vs methods
  • 【C++闯关笔记】STL:string的学习和使用(万字精讲)
  • 开发软件安装记录
  • Kubernetes v1.34 前瞻:资源管理、安全与可观测性的全面进化
  • golang6 条件循环
  • R语言rbind()和cbind()使用
  • 信贷策略域——信贷产品策略设计
  • 【数据结构】排序算法全解析
  • 【链表 - LeetCode】206. 反转链表【带ACM调试】
  • HTTP URL 详解:互联网资源的精准地址
  • 当AI遇上终端:Gemini CLI的技术魔法与架构奥秘
  • 在 vue3 和 vue2 中,computed 计算属性和 methods 方法区别是什么
  • 打响“A+H”双重上市突围战,云天励飞实力如何?
  • JUC并发编程07 - wait-ify/park-un/安全分析
  • 《CF1120D Power Tree》
  • Spirng Cloud Alibaba主流组件
  • 【ElasticSearch】springboot整合es案例
  • 企业出海第一步:国际化和本地化
  • springBoot如何加载类(以atomikos框架中的事务类为例)
  • JavaScript数据结构详解
  • Docker知识点
  • 【数据分享】中国地势三级阶梯矢量数据
  • 【无标题】对六边形拓扑结构中的顶点关系、着色约束及量子隧穿机制进行严谨论述。