已开启
[MLIR][Transform] transform.legalize 对 SVE 可伸缩向量按静态 shape 计算展开因子,生成非法 IR #131
cactusBalll创建于  3 天前
cactusBalll
3 天前 创建

【缺陷描述】:请补充详细的缺陷问题现象描述

对合法的 SVE 可伸缩向量 IR:

func.func @scalable_mulf(%a: vector<[8]xf32>, %b: vector<[8]xf32>) -> vector<[8]xf32> {
  %0 = arith.mulf %a, %b : vector<[8]xf32>
  return %0 : vector<[8]xf32>
}

运行 transform.legalize--transform-interpreter)失败:

error: 'vector.extract_strided_slice' op expected size at idx=0 to match the
corresponding base size from the input vector (4 vs 8)
note: see current operation: %1 = "vector.extract_strided_slice"(%arg0)
      <{offsets = [0], sizes = [4], strides = [1]}>
      : (vector<[8]xf32>) -> vector<4xf32>

生成的 extract_strided_slice 用静态尺寸 (4) 切分可伸缩向量(vector<[8]xf32>),verifier 拒绝(可伸缩维度只能整维切分);mlir-opt exit 1 无输出。2-D SME 形态 vector<[8]x[8]xf32>(sizes [4,4])同样失败。此前提交 14314cbd "Fix SVE and SME crash on the transform dialect" 声称修复 SVE/SME 场景,但 legalize 路径对 SVE 载荷依然不可用。

一、缺陷信息

  • 缺陷组件:MLIR Transform dialect(TransformOps.cpp,LegalizeOp::getShape;pattern 由厂商提交 0d042c157 "legalize" 引入)
  • 缺陷类型:生成非法 IR / 合法输入被拒(pass 硬失败,exit 1)
  • 根因:TransformOps.cpp:3314-3327 LegalizeOp::getShapedstVecType.getShape() 取形状——getShape() 把每 lane 计数(8)当作静态尺寸返回,不检查 isScalable()getAllDimsMaxUnrollingFactor 据此返回静态 native shape([4]),vector unroll 模式随即发射静态尺寸的 extract/insert_strided_slice 作用于 scalable 向量。同一提交(1f9b0b2e,rank-0 修复)已为空形状加了 if (dstShape.size() == 0) return std::nullopt; 的 bail-out,但漏了 scalable
  • 相关提交
    • 0d042c157b7a65ee48ab2920b67f95113f9347da "legalize"(引入 pattern)
    • 1f9b0b2eda7bdee1c3b13615d535795eb7bfd4ad "[MLIR][Transform] BugFix Legalization on vector with rank 0"(同函数加了 rank-0 bail-out,未覆盖 scalable;分支合并 !526)
    • 14314cbd6d0b0b5bd39fd1f256c4122a2666651c "Fix SVE and SME crash on the transform dialect"(修复 interpreter 崩溃但 legalize 仍失败)

【缺陷所属的os版本】

Ubuntu 22.04.3 LTS 缺陷位于编译器/MLIR 工具链本身,与操作系统版本无关。

【内核版本】

6.6.87.2-microsoft-standard-WSL2(uname -r)。缺陷与内核版本无关。

【缺陷所属软件及版本号】

LLVM 20.1.8

【环境信息】

编译选项:
CMAKE_BUILD_TYPE=RelWithDebInfo,LLVM_ENABLE_ASSERTIONS=ON,LLVM_ENABLE_PROJECTS="clang;mlir",LLVM_TARGETS_TO_BUILD="X86;AArch64"

COMMIT ID:35f464110c04e89bd0cab0e3fee4a70ec6ec2eb9

【问题复现步骤】

// BUG: transform.legalize on SVE scalable vectors generates invalid IR.
// Commit 1f9b0b2e "[MLIR][Transform] BugFix Legalization on vector with rank 0"
// (root cause is in LegalizeOp::getShape from commit 0d042c157 "legalize").
//
// The payload is legal MLIR (scalable SVE vector arithmetic). transform.legalize
// computes a native unroll shape for the scalable dim as if it were static and
// the vector unroller emits `vector.extract_strided_slice` with static sizes on
// a scalable base vector, which fails verification.
func.func @scalable_mulf(%a: vector<[8]xf32>, %b: vector<[8]xf32>) -> vector<[8]xf32> {
  %0 = arith.mulf %a, %b : vector<[8]xf32>
  return %0 : vector<[8]xf32>
}

module attributes {transform.with_named_sequence} {
  transform.named_sequence @__transform_main(%arg0: !transform.any_op) {
    transform.legalize
    transform.yield
  }
}

执行mlir-opt test.mlir --transform-interpreter报错

【实际结果】

【期望结果】

【其他相关附件信息】

【缺陷详情及分析指导参考链接】

likedislike
openeuler-ci-botopeneuler-ci-bot成员
3 天前 将 alexanderbill、li-yancheng、cf-zhao、eastb233、wangqiang95、kuenking111_admin、SegFault、wd-gitcode、chenzheng1030、gcw_LWQavIsb 设为负责人
openeuler-ci-botopeneuler-ci-bot成员
3 天前 添加了label:sig/Compiler
openeuler-ci-bot
openeuler-ci-bot成员
3 天前 评论:

Welcome To openEuler Community

Hey @gcw_LWQavIsb , thanks for your contribution to the community.

Bot Usage Manual

I'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands. You can self-configure the PR merge rules for this repository. For more details, please refer to Here.

Contact Guide

If you have any questions, please contact the SIG: Compiler ,
and any of the maintainers: @SegFault, @alexanderbill, @cf-zhao, @chenzheng1030, @eastb233, @kuenking111_admin, @li-yancheng, @wangqiang95, @wd-gitcode ,
and any of the committers: @liyunfei33, @zhongyunde .

likedislike