[Mlir-commits] [mlir] [mlir][sparse] Replace `getSparseTensorType` with `tryGetSparseTensorType` (PR #109435)

Longsheng Mou llvmlistbot at llvm.org
Fri Sep 20 18:15:50 PDT 2024


CoTinker wrote:

Thanks for the response. You’re correct that sparse tensors are ranked. However, to maintain the robustness of this pattern, the compiler should handle invalid inputs, such as `unranked tensors`, by returning `failure()` gracefully, rather than crashing.
Such as:
```
auto stt = tryGetSparseTensorType(op.getSource());
if (!dim || !stt || !stt->hasEncoding())
   return failure();
```

https://github.com/llvm/llvm-project/pull/109435


More information about the Mlir-commits mailing list