[all-commits] [llvm/llvm-project] 8d082c: [mlir][sparse] Fix crash in sparse_tensor.new with...

Mehdi Amini via All-commits all-commits at lists.llvm.org
Tue Mar 3 03:42:36 PST 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8d082c7c3144c0a635031387bf7bf6d60960ab9e
      https://github.com/llvm/llvm-project/commit/8d082c7c3144c0a635031387bf7bf6d60960ab9e
  Author: Mehdi Amini <joker.eph at gmail.com>
  Date:   2026-03-03 (Tue, 03 Mar 2026)

  Changed paths:
    M mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
    M mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.cpp
    M mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.h
    A mlir/test/Dialect/SparseTensor/conversion_invalid.mlir

  Log Message:
  -----------
  [mlir][sparse] Fix crash in sparse_tensor.new with unsupported element type (#183898)

sparse_tensor.new with an element type not supported by the sparse
tensor runtime library (e.g. `index`) would call primaryTypeEncoding(),
which hits an llvm_unreachable("Unknown primary type"). The runtime
library only supports fixed-width types (f64/f32/f16/bf16,
i64/i32/i16/i8, and complex<f32/f64>); platform-dependent types such as
`index` have no corresponding PrimaryType encoding.

Fix by adding an isValidPrimaryType() helper and checking it in
SparseTensorNewConverter::matchAndRewrite() before calling genReader(),
so the conversion fails gracefully instead of crashing.

Fixes #180310



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list