mirror of https://github.com/llvm/torch-mlir
Fix TorchToIREE lowering.
We needed to resize the list, not just reserve capacity.pull/300/head
parent
600cc6b9c7
commit
ed2afe43e7
|
@ -35,10 +35,11 @@ public:
|
|||
matchAndRewrite(PrimListConstructOp op, ArrayRef<Value> operands,
|
||||
ConversionPatternRewriter &rewriter) const override {
|
||||
auto type = getTypeConverter()->convertType(op.getType());
|
||||
auto capacity =
|
||||
auto size =
|
||||
rewriter.create<ConstantIndexOp>(op.getLoc(), op->getNumOperands());
|
||||
auto ireeList =
|
||||
rewriter.replaceOpWithNewOp<iree::ListCreateOp>(op, type, capacity);
|
||||
rewriter.replaceOpWithNewOp<iree::ListCreateOp>(op, type, size);
|
||||
rewriter.create<iree::ListResizeOp>(op.getLoc(), ireeList, size);
|
||||
for (int i = 0, e = operands.size(); i != e; ++i) {
|
||||
auto index = rewriter.create<ConstantIndexOp>(op.getLoc(), i);
|
||||
rewriter.create<iree::ListSetOp>(op.getLoc(), ireeList, index,
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
// CHECK: %[[ALSO_ARG:.*]] = torch_c.to_f64 %[[ARG_TORCH]]
|
||||
// CHECK: %[[C2:.*]] = constant 2 : index
|
||||
// CHECK: %[[LIST:.*]] = iree.list.create %[[C2]] : !iree.list<f64>
|
||||
// CHECK: iree.list.resize %[[LIST]], %[[C2]] : !iree.list<f64>
|
||||
// CHECK: %[[C0:.*]] = constant 0 : index
|
||||
// CHECK: iree.list.set %[[LIST]][%[[C0]]], %[[ARG]] : !iree.list<f64>, f64
|
||||
// CHECK: %[[C1:.*]] = constant 1 : index
|
||||
|
|
Loading…
Reference in New Issue