mlir 编译器学习笔记之十 -- 数据类型

1、MLIR区分三种整数类型

IntegerType::get(context, 32, IntegerType::Signless); // 简写IntegerType::get(context, 32)

IntegerType::get(context, 32, IntegerType::Signed);

IntegerType::get(context, 32, IntegerType::Unsigned);

在 mlir/include/mlir/IR/BuiltinTypes.td中定义,所以td中i32/si32/ui32 是三种不同的数据类型

在开源CppEmitter::shouldMapToUnsigned中定义映射,Signless保存和Signed一致

在 mlir/include/mlir/Dialect/Arith/IR/ArithOps.td中Arith_IndexCastOp仅支持不带符号信息的数据类型SignlessInteger

2、自定义结构图类型:

hlc.struct_def @DemoKernelL1dAddr {

"totalBytes" : i32,

"bdAddrBase" : i32,

"buffer0" : i64,

"buffer1" : i64

}

hlc.struct_def @DemoKernelPara {

"l1dAddr" : !hlc.struct<@DemoKernelL1dAddr>

}

在主函数中需要将分离的参数和结构体进行绑定:结构体存储的是地址,get_field 取出地址,pointer_cast 转换为内存视图

3、MLIR 的 arith 方言只允许 i64(signless)

可以通过增加属性 constOp->setAttr("xxx", UnitAttr::get(rewriter.getContext())); 做区分

相关推荐
xian_wwq7 分钟前
【学习笔记】深度认知系列-第10讲AI绘画与设计——从Stable Diffusion到Midjourney
笔记·学习·ai作画
凯尔萨厮9 分钟前
Java学习笔记十五(GUI)
java·笔记·学习
陈年老古董16 分钟前
矿物分类实战:从传统机器学习到深度学习(含PyTorch实现)
笔记·深度学习·学习·机器学习·分类
咖啡忍者17 分钟前
【SAP】100小时学会SAP-5生产计划PP
笔记
春风解人意21 分钟前
从零开始学习嵌入式P35----数据库
数据库·嵌入式硬件·学习
sunoo-22923 分钟前
【网络编程 + 数据库】select 与 epoll 核心区别详解 + SQLite 入门到 C 接口全攻略
linux·网络·数据库·vscode·学习·sqlite
摇滚侠29 分钟前
《SpringBoot 3:入门与应用实战》第 13 章 整合 MyBatis MyBatis 简单开发 阅读笔记 39
spring boot·笔记·mybatis
xieliyu.1 小时前
计算机网络:Fiddler 抓包工具使用教程 + HTTP 协议报文格式详解
java·笔记·计算机网络·测试工具·http·java-ee·fiddler
koi77u1 小时前
嵌入式学习———sqlite数据表
linux·数据库·学习·sqlite
老王爱玩车1 小时前
汉诺塔 + 青蛙跳台阶问题
学习