This is a beginner level question. So, I have to implement toy.delay operation with 2 input arguments, a vector and a single tensor. Here, this operation is just a shift in data ie, for a vector of size 3 – [10, 20, 30 ] , and unit = 2, output will be [0 , 0, 10].
Now, when I am lowering it to affine loops – what should be the right way to buildAffineLoopNest when the upper index ex- %5 below is coming from an operation and not an attribute? I am assuming this has to be converted to arith::ConstantIndexOp & for this, we need an integer constant value but this is not a constant but rather a SSA value which can’t be casted to IntegerAttr –
%3 = toy.add %1, %2 : tensor<f64>
%4 = arith.fptoui %3 : ui
%5 = arith.ConstanIndex %4 : index
affine.for %arg0 = 0 to %5 {
affine.store %cst,%alloc[%arg0]:memref<3xf64>
}
Also, for the affine-map , can we use SSA value and not a constant value ie,
#map2 = affine_map<(d0) -> (d0 + %4)>
Is this allowed in MLIR to use SSA values for affine-loop indices and affine-map? If yes, what is the correct sequence from say, tensor<f64>
to affine-loop index and affine-map? I have tried tensor<f64>
→ arith.ui → arith.index but I am getting the error : error: failed to materialize conversion for result #0 of operation ‘toy.constant’ that remained live after conversion . Any particular example code would be really helpful.