-
Notifications
You must be signed in to change notification settings - Fork 650
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
iree_gpu
Python bindings (GPUPipelineOptionsAttr
)
#18804
iree_gpu
Python bindings (GPUPipelineOptionsAttr
)
#18804
Conversation
b763d83
to
56147f4
Compare
iree_gpu
Python bindings
56147f4
to
07d77ec
Compare
07d77ec
to
1e8b9a9
Compare
compiler/src/iree/compiler/Codegen/Dialect/GPU/IR/IREEGPUAttrs.td
Outdated
Show resolved
Hide resolved
238144e
to
035e5bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks for plumbing this through
compiler/src/iree/compiler/Codegen/Dialect/GPU/IR/IREEGPUAttrs.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Dialect/GPU/IR/IREEGPUAttrs.cpp
Outdated
Show resolved
Hide resolved
There's a printer ambiguity due to poor dispatch layering in AttrOrTypeFormatGen.cpp: consider
which currently generates void ReorderWorkgroupsStrategyAttr::print(::mlir::AsmPrinter &odsPrinter) const {
::mlir::Builder odsBuilder(getContext());
// shouldEmitSpace: 1
// !lastWasPunctuation: 1
odsPrinter << ' ';
odsPrinter << stringifyReorderWorkgroupsStrategy(getValue());
} (where I've inlined the values of This prints the following // IREEGPU_ReorderWorkgroupsStrategyAttr alone
#iree_gpu<reorder_work_groups_strategy Swizzle>
// IREEGPU_ReorderWorkgroupsStrategyAttr as a Parameter to IREEGPU_GPUPipelineOptionsAttr
#iree_gpu.pipeline_options<prefetch_shared_memory = true, no_reduce_shared_memory_bank_conflicts = false, reorder_workgroups_strategy = Swizzle> Note the extra space in The reason this happens is because in the latter case, the printer void GPUPipelineOptionsAttr::print(::mlir::AsmPrinter &odsPrinter) const {
::mlir::Builder odsBuilder(getContext());
odsPrinter << "<";
{
...
if (!(getReorderWorkgroupsStrategy() == ReorderWorkgroupsStrategyAttr())) {
if (!_firstPrinted) odsPrinter << ", ";
_firstPrinted = false;
odsPrinter << "reorder_workgroups_strategy = ";
if (!(getReorderWorkgroupsStrategy() == ReorderWorkgroupsStrategyAttr())) {
// shouldEmitSpace: 0
// !lastWasPunctuation: 0
odsPrinter.printStrippedAttrOrType(getReorderWorkgroupsStrategy());
}
}
}
odsPrinter << ">";
} but I believe the logical error is in pushing the responsibility of diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
--- a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp (revision a758bcdbd92efb64a3482eb95d2769d74e33f5bb)
+++ b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp (date 1729175762504)
@@ -932,7 +932,7 @@
printer.body() << " return ::llvm::TypeSwitch<::mlir::" << valueType
<< ", ::llvm::LogicalResult>(def)";
const char *const printValue = R"( .Case<{0}>([&](auto t) {{
- printer << {0}::getMnemonic();{1}
+ printer << {0}::getMnemonic() << ' ';{1}
return ::mlir::success();
})
)";
diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp
--- a/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp (revision a758bcdbd92efb64a3482eb95d2769d74e33f5bb)
+++ b/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp (date 1729175930071)
@@ -783,12 +783,6 @@
os.indent();
}
- // Insert a space before the next parameter, if necessary.
- if (shouldEmitSpace || !lastWasPunctuation)
- os << tgfmt("$_printer << ' ';\n", &ctx);
- shouldEmitSpace = true;
- lastWasPunctuation = false;
-
if (el->shouldBeQualified())
os << tgfmt(qualifiedParameterPrinter, &ctx) << ";\n";
else if (auto printer = param.getPrinter()) It produces the following prints (transcribing the "before"): // before
#iree_gpu<reorder_work_groups_strategy Swizzle>
#iree_gpu.pipeline_options<prefetch_shared_memory = true, no_reduce_shared_memory_bank_conflicts = false, reorder_workgroups_strategy = Swizzle>
// after
#iree_gpu<reorder_work_groups_strategy Swizzle>
#iree_gpu<pipeline_options <prefetch_shared_memory = true, no_reduce_shared_memory_bank_conflicts = false, reorder_workgroups_strategy = Swizzle>> Note, the reason that the aggregate attribute is printed so differently is because somewhere (I have no found where...) someone is making a decision about whether it should be If we are in agreement that this is a problem I can fully explore/investigate/fix. |
Signed-off-by: makslevental <[email protected]>
035e5bc
to
b3c78fb
Compare
Gah. Does it make it print weird with the extra space or not work with bindings at all? @makslevental If it's the former, I think we can live with the extra space. I've run into this before but never found the cycles to fully investigate (context) |
I actually meant to post/paste that whole thing to upstream.................
It prints with the extra space. The other alternative that would tidy things up here is to change the assembly for
which will generate prints like #iree_gpu.pipeline_options<prefetch_shared_memory = true, no_reduce_shared_memory_bank_conflicts = false, reorder_workgroups_strategy = <Swizzle>>
#iree_gpu.reorder_work_groups_strategy<Swizzle> I don't love it but I don't hate it either 🤷 |
22b63e1
to
76825d3
Compare
iree_gpu
Python bindingsiree_gpu
Python bindings (GPUPipelineOptionsAttr
)
compiler/src/iree/compiler/Codegen/Dialect/GPU/IR/IREEGPUAttrs.cpp
Outdated
Show resolved
Hide resolved
Signed-off-by: makslevental <[email protected]>
Signed-off-by: makslevental <[email protected]>
76825d3
to
d57a6be
Compare
6163a4e
to
d57a6be
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@stellaraccident if you could give us your blessing we'd appreciate it :) |
Signed-off-by: makslevental <[email protected]>
48b3e0e
to
9035cab
Compare
9035cab
to
cb9f9ca
Compare
Signed-off-by: makslevental <[email protected]>
cb9f9ca
to
8298ddb
Compare
Seeing Windows build errors pointing to this: https://gist.github.com/ScottTodd/bed7de027adeafea6a7f31bf113c2284 CI has a different build error that might be triggering first, so I can't tell if this is unique to my machine/environment yet. |
This reverts commit fb18c42.
Sent a PR to revert: #18833. Also trying some things to fix: main...ScottTodd:iree:ireegpu-api-fixes |
These files being outdated has been a source of build errors before. Updating using [`compiler/src/iree/compiler/API/generate_exports.py`](https://github.com/iree-org/iree/blob/main/compiler/src/iree/compiler/API/generate_exports.py) (as-is) doesn't help with the latest errors (#18804 (comment)), but it shouldn't hurt.
Reverts #18804 This broke local builds on Windows: #18804 (comment).
My bad - I'd seen all the |
If you can iterate on it and fix it yourself, that would be great. What I have there is part of the puzzle. I still get the same error messages though. The object file linking across C APIs and Python bindings has a few tricky details and differences across platforms. |
Reland #18804 including main...ScottTodd:iree:ireegpu-api-fixes but also with (currently) a hack for exposing symbols in `compiler/src/iree/compiler/Codegen/Dialect/GPU/IR/IREEGPUAttrs.cpp`. TODO - [x] decide/find the right way to expose symbols in `IREEGPUAttrs.cpp` on windows (alternatively move those C APIs) EDIT: moved C wrappers to `compiler/src/iree/compiler/API/Internal/IREEGPUDialectCAPI.cpp`. win CI job: https://github.com/iree-org/iree/actions/runs/11411731188 --------- Signed-off-by: Maksim Levental <[email protected]>
TODO:
ReorderWorkgroupsStrategy
(which is an enum)