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

mlir CollapseShapeOp ExpandShapeOp的构造

作用
CollapseShapeOp把一些维度合并,总Tensor的size不变;ExpandShapeOp把一些维度拆开,总Tensor的size不变。
create方式

SmallVector<int64_t> rhsShapeSimplified;
auto targetRhsType = RankedTensorType::get(rhsShapeSimplified, cast<RankedTensorType>(rhsType).getElementType());
rhsToRewriter =rewriter.create<tensor::CollapseShapeOp>(op->getLoc(), targetRhsType(目标type), op->getOperand(1)(原始value), rhsReassociation);

Reassociation: 输入Tensor到输出Tensor对应的维度坐标信息:把哪些维度合并在一起
rhsReassociation类型是SmallVector本质是SmallVector<SmallVector<int64_t>>

tensor<1x1x1x4x3xf16> reassociation: [[0, 1, 2, 3], [4]]; 
tensor<1x3x4xf16> reassociation: [[0, 1], [2]]auto targetOutType = RankedTensorType::get(outShape, cast<RankedTensorType>(outType).getElementType());lastToReplace = rewriter.create<tensor::ExpandShapeOp>(op->getLoc(), targetOutType, matmul, outReassociation);

Reassociation: 输出Tensor到输入Tensor对应的维度坐标信息:把哪些维度合并在一起

获取Reassociation的方式,可以直接调三方接口

std::optional<SmallVector<ReassociationIndices>>
mlir::getReassociationIndicesForCollapse(ArrayRef<int64_t> sourceShape,ArrayRef<int64_t> targetShape)
http://www.xdnf.cn/news/18333.html

相关文章:

  • 循环神经网络实战:用 LSTM 做中文情感分析(二)
  • Class A 包含字段 x Class B 也包含字段 x,如果判断List<A> lista 和 List<B> listb 有相同的 x?
  • 29、工业网络威胁检测与响应 (IDS 模拟) - /安全与维护组件/industrial-network-ids
  • spark数据缓存机制
  • 云计算下数据隐私保护系统的设计与实现(LW+源码+讲解+部署)
  • [RestGPT] docs | RestBench评估 | 配置与环境
  • 阿里云的centos8 服务器安装MySQL 8.0
  • 【OpenGL】LearnOpenGL学习笔记13 - 深度测试、模板测试
  • Linux CentOS 安装 .net core 3.1
  • 1. 准备工作---数据分析编程 - 从入门到精通
  • 密码学——对称加密, 非对称加密和CA
  • 基于SpringBoot的流浪动物领养管理系统【2026最新】
  • 常见的端口扫描
  • 常德二院全栈国产化信创项目:开启医疗新质生产力的“头雁”之旅
  • Android 定位技术全解析:从基础实现到精准优化
  • 数据大屏全链路质量保障测试
  • 消息中间件(RocketMQ+RabbitMQ+Kafka)
  • C++手撕LRU
  • RocketMQ 消息消费 单个消费和批量消费配置实现对比(Springboot),完整实现示例对比
  • 链表-143.重排链表-力扣(LeetCode)
  • SQL视图、存储过程和触发器
  • npm全局安装后,cmd命令行可以访问,vscode访问报错
  • Django REST框架核心:GenericAPIView详解
  • GitHub Push 认证失败 fatal Authentication failed
  • OceanBase 分区裁剪(Partition Pruning)原理解读
  • Binlog Server守护MySQL数据0丢失
  • 基于Pytochvideo训练自己的的视频分类模型
  • python中view把矩阵维度降低的时候是什么一个排序顺序
  • 机器学习——数据清洗
  • 【论文阅读】Multi-metrics adaptively identifies backdoors in Federated Learning