| 46 | /// @brief Search the given Module for the function with provided name. |
| 47 | template <bool noThrow = false> |
| 48 | mlir::func::FuncOp getKernelFuncOp(mlir::ModuleOp mod, |
| 49 | const std::string &name) { |
| 50 | std::string lookupName = name; |
| 51 | if (mod->hasAttr(cudaq::runtime::pythonUniqueAttrName)) { |
| 52 | mlir::StringRef uniqName = cast<mlir::StringAttr>( |
| 53 | mod->getAttr(cudaq::runtime::pythonUniqueAttrName)); |
| 54 | if (uniqName.substr(0, name.size()) == name) { |
| 55 | // FIXME: The path to this call used the wrong name. |
| 56 | lookupName = uniqName; |
| 57 | } |
| 58 | } |
| 59 | lookupName = cudaq::runtime::cudaqGenPrefixName + lookupName; |
| 60 | if (auto result = mod.lookupSymbol<mlir::func::FuncOp>(lookupName)) |
| 61 | return result; |
| 62 | if constexpr (noThrow) { |
| 63 | return {}; |
| 64 | } else /*constexpr*/ { |
| 65 | mod.dump(); |
| 66 | throw std::runtime_error("Could not find " + lookupName + |
| 67 | " function in current module."); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | template <bool noThrow = false> |
| 72 | mlir::func::FuncOp getKernelFuncOp(MlirModule module, |
no test coverage detected