From ebd224c2199a003b2951fbeaa10daab88041762d Mon Sep 17 00:00:00 2001 From: shardy authors Date: Fri, 25 Oct 2024 12:56:47 -0700 Subject: [PATCH] Fix a bug in the insert_explicit_reshards pass on OSS tests. It fails with the following error: error: reference to local binding 'index' declared in enclosing function PiperOrigin-RevId: 689883771 --- .../dialect/sdy/transforms/export/insert_explicit_reshards.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shardy/dialect/sdy/transforms/export/insert_explicit_reshards.cc b/shardy/dialect/sdy/transforms/export/insert_explicit_reshards.cc index 4eddef7..715f1e7 100644 --- a/shardy/dialect/sdy/transforms/export/insert_explicit_reshards.cc +++ b/shardy/dialect/sdy/transforms/export/insert_explicit_reshards.cc @@ -131,7 +131,8 @@ void insertExplicitReshards(Operation* op, const ShardingProjection& projection, } auto reshardOp = rewriter.create(value.getLoc(), value, newTensorSharding); - rewriter.modifyOpInPlace(op, [&]() { op->setOperand(index, reshardOp); }); + rewriter.modifyOpInPlace( + op, [&, index = index]() { op->setOperand(index, reshardOp); }); } rewriter.setInsertionPointAfter(op);