[Mlir-commits] [mlir] [mlir][sparse] fold explicit value during sparsification (PR #90530)

Peiming Liu llvmlistbot at llvm.org
Mon Apr 29 15:45:13 PDT 2024


================
@@ -498,9 +498,17 @@ static Value genTensorLoad(CodegenEnv &env, OpBuilder &builder, ExprId exp) {
   Value val = env.exp(exp).val;
   if (val)
     return val;
-  // Load during insertion.
+  // Get tensor operand.
   linalg::GenericOp op = env.op();
+  Location loc = op.getLoc();
   OpOperand *t = &op->getOpOperand(env.exp(exp).tensor);
+  // Fold binary-valued tensor into explicit value.
+  const auto stt = getSparseTensorType(t->get());
+  if (stt.hasEncoding()) {
+    if (auto explVal = stt.getExplicitVal())
----------------
PeimingLiu wrote:

nit: Can we implement `stt::getExplicitVal` as `return enc ? enc.getExplicitVal() : nullptr` to fuse two if statements?

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


More information about the Mlir-commits mailing list