[Mlir-commits] [mlir] [mlir] Method to iterate over registered operations for a given dialect class. (PR #112344)
River Riddle
llvmlistbot at llvm.org
Wed Oct 16 12:49:06 PDT 2024
================
@@ -711,6 +714,27 @@ ArrayRef<RegisteredOperationName> MLIRContext::getRegisteredOperations() {
return impl->sortedRegisteredOperations;
}
+/// Return information for registered operations by dialect.
+ArrayRef<RegisteredOperationName>
+MLIRContext::getRegisteredOperationsByDialect(StringRef dialectName) {
+ auto lowerBound =
+ std::lower_bound(impl->sortedRegisteredOperations.begin(),
+ impl->sortedRegisteredOperations.end(), dialectName,
+ [](auto &lhs, auto &rhs) {
+ return lhs.getDialect().getNamespace().compare(
+ rhs.getDialect().getNamespace());
+ });
+
+ auto upperBound =
+ std::lower_bound(lowerBound, impl->sortedRegisteredOperations.end(),
+ dialectName, [](auto &lhs, auto &rhs) {
+ return lhs.getDialect().getNamespace().compare(
+ rhs.getDialect().getNamespace());
+ });
----------------
River707 wrote:
You shouldn't need to compute the upper bound here, you should be able to use the operationCount that is computed in the dialect. That can be grabbed from the first operation of the lowerBound (after checking it's dialect is the same as the input, to account for no operations for the dialect).
https://github.com/llvm/llvm-project/pull/112344
More information about the Mlir-commits
mailing list