Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoBump] Merge with fixes of fef3566a (Oct 01, needs downstream change) (6) #443

Open
wants to merge 2 commits into
base: feature/fused-ops
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mlir/include/mlir/Transforms/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define MLIR_TRANSFORMS_PASSES_H

#include "mlir/Pass/Pass.h"
#include "mlir/Pass/PassManager.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "mlir/Transforms/LocationSnapshot.h"
#include "mlir/Transforms/ViewOpGraph.h"
Expand Down
6 changes: 4 additions & 2 deletions mlir/lib/Dialect/Arith/Transforms/IntNarrowing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ struct NarrowingPattern : OpRewritePattern<SourceOp> {
NarrowingPattern(MLIRContext *ctx, const ArithIntNarrowingOptions &options,
PatternBenefit benefit = 1)
: OpRewritePattern<SourceOp>(ctx, benefit),
supportedBitwidths(options.bitwidthsSupported) {
supportedBitwidths(options.bitwidthsSupported.begin(),
options.bitwidthsSupported.end()) {
assert(!supportedBitwidths.empty() && "Invalid options");
assert(!llvm::is_contained(supportedBitwidths, 0) && "Invalid bitwidth");
llvm::sort(supportedBitwidths);
Expand Down Expand Up @@ -757,7 +758,8 @@ struct ArithIntNarrowingPass final
MLIRContext *ctx = op->getContext();
RewritePatternSet patterns(ctx);
populateArithIntNarrowingPatterns(
patterns, ArithIntNarrowingOptions{bitwidthsSupported});
patterns, ArithIntNarrowingOptions{
llvm::to_vector_of<unsigned>(bitwidthsSupported)});
if (failed(applyPatternsAndFoldGreedily(op, std::move(patterns))))
signalPassFailure();
}
Expand Down
20 changes: 10 additions & 10 deletions mlir/tools/mlir-tblgen/PassGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static void emitPassOptionsStruct(const Pass &pass, raw_ostream &os) {
std::string type = opt.getType().str();

if (opt.isListOption())
type = "::llvm::ArrayRef<" + type + ">";
type = "::llvm::SmallVector<" + type + ">";

os.indent(2) << llvm::formatv("{0} {1}", type, opt.getCppVariableName());

Expand Down Expand Up @@ -128,8 +128,8 @@ static void emitPassDecls(const Pass &pass, raw_ostream &os) {

// Declaration of the constructor with options.
if (ArrayRef<PassOption> options = pass.getOptions(); !options.empty())
os << llvm::formatv("std::unique_ptr<::mlir::Pass> create{0}(const "
"{0}Options &options);\n",
os << llvm::formatv("std::unique_ptr<::mlir::Pass> create{0}("
"{0}Options options);\n",
passName);
}

Expand Down Expand Up @@ -236,7 +236,7 @@ namespace impl {{

const char *const friendDefaultConstructorWithOptionsDeclTemplate = R"(
namespace impl {{
std::unique_ptr<::mlir::Pass> create{0}(const {0}Options &options);
std::unique_ptr<::mlir::Pass> create{0}({0}Options options);
} // namespace impl
)";

Expand All @@ -247,8 +247,8 @@ const char *const friendDefaultConstructorDefTemplate = R"(
)";

const char *const friendDefaultConstructorWithOptionsDefTemplate = R"(
friend std::unique_ptr<::mlir::Pass> create{0}(const {0}Options &options) {{
return std::make_unique<DerivedT>(options);
friend std::unique_ptr<::mlir::Pass> create{0}({0}Options options) {{
return std::make_unique<DerivedT>(std::move(options));
}
)";

Expand All @@ -259,8 +259,8 @@ std::unique_ptr<::mlir::Pass> create{0}() {{
)";

const char *const defaultConstructorWithOptionsDefTemplate = R"(
std::unique_ptr<::mlir::Pass> create{0}(const {0}Options &options) {{
return impl::create{0}(options);
std::unique_ptr<::mlir::Pass> create{0}({0}Options options) {{
return impl::create{0}(std::move(options));
}
)";

Expand Down Expand Up @@ -326,10 +326,10 @@ static void emitPassDefs(const Pass &pass, raw_ostream &os) {

if (ArrayRef<PassOption> options = pass.getOptions(); !options.empty()) {
os.indent(2) << llvm::formatv(
"{0}Base(const {0}Options &options) : {0}Base() {{\n", passName);
"{0}Base({0}Options options) : {0}Base() {{\n", passName);

for (const PassOption &opt : pass.getOptions())
os.indent(4) << llvm::formatv("{0} = options.{0};\n",
os.indent(4) << llvm::formatv("{0} = std::move(options.{0});\n",
opt.getCppVariableName());

os.indent(2) << "}\n";
Expand Down
3 changes: 1 addition & 2 deletions mlir/unittests/TableGen/PassGenTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ TEST(PassGenTest, PassOptions) {
TestPassWithOptionsOptions options;
options.testOption = 57;

llvm::SmallVector<int64_t, 2> testListOption = {1, 2};
options.testListOption = testListOption;
options.testListOption = {1, 2};

const auto unwrap = [](const std::unique_ptr<mlir::Pass> &pass) {
return static_cast<const TestPassWithOptions *>(pass.get());
Expand Down
Loading