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

Aart Bik llvmlistbot at llvm.org
Mon Apr 29 15:48:48 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())
----------------
aartbik wrote:

We think alike, I noticed that too. Seems cleaner indeed.

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


More information about the Mlir-commits mailing list