Skip to content

Commit

Permalink
Avoid explicitly constructing compatible attributes in a few places (#…
Browse files Browse the repository at this point in the history
…1958)

Attrs will be implicitly copied. Avoid explicitly constructing the attrs
as this introduces a dependency on the type of the attrs, meaning the
code will need to be changed if the attrs' type changes. (Indeed I had
to change this code recently when we changed the attrs from
DenseIntElementsAttr to DenseI64ArrayAttr).
  • Loading branch information
mlevesquedion authored Jan 26, 2024
1 parent d4cb569 commit 00ae7d4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -831,11 +831,8 @@ struct TransposeOpToTransposeConverter final
Value emptyTensor =
getEmptyTensorFor(rewriter, loc, resultTy, op, adaptor.getOperands());

auto permutation =
rewriter.getDenseI64ArrayAttr(llvm::to_vector(op.getPermutation()));

rewriter.replaceOpWithNewOp<linalg::TransposeOp>(
op, adaptor.getOperand(), emptyTensor, permutation,
op, adaptor.getOperand(), emptyTensor, op.getPermutationAttr(),
linalg::getPrunedAttributeList(op));
return success();
}
Expand Down
3 changes: 1 addition & 2 deletions stablehlo/transforms/StablehloCanonicalizeDynamism.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ struct CanonicalizeDynamicBroadcastInDimOpPattern
if (!op.getType().hasStaticShape())
return rewriter.notifyMatchFailure(op, "expected static result type");
rewriter.replaceOpWithNewOp<BroadcastInDimOp>(
op, op.getType(), op.getOperand(),
rewriter.getDenseI64ArrayAttr(op.getBroadcastDimensions()));
op, op.getType(), op.getOperand(), op.getBroadcastDimensionsAttr());
return success();
}
};
Expand Down

0 comments on commit 00ae7d4

Please sign in to comment.