Skip to content

Commit

Permalink
fix to_qir function
Browse files Browse the repository at this point in the history
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
  • Loading branch information
amccaskey committed Mar 25, 2024
1 parent c1d65f3 commit 8764dc2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
5 changes: 3 additions & 2 deletions python/runtime/cudaq/platform/py_alt_launch_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,9 @@ void bindAltLaunchKernel(py::module &mod) {
auto name = kernel.attr("name").cast<std::string>();
auto kernelFuncOp = getKernelFuncOp(module, name);
cudaq::OpaqueArguments args;
cudaq::packArgs(args, runtimeArgs, kernelFuncOp,
[](OpaqueArguments &, py::object &) { return false; });
cudaq::packArgs(
args, runtimeArgs, kernelFuncOp,
[](OpaqueArguments &, py::object &) { return false; }, false);
return getQIRLL(name, module, args, profile);
},
py::arg("kernel"), py::kw_only(), py::arg("profile") = "");
Expand Down
21 changes: 11 additions & 10 deletions python/utils/OpaqueArguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,17 @@ inline mlir::func::FuncOp getKernelFuncOp(MlirModule module,
return kernelFunc;
}

inline void
packArgs(OpaqueArguments &argData, py::args args,
mlir::func::FuncOp kernelFuncOp,
const std::function<bool(OpaqueArguments &argData, py::object &arg)>
&backupHandler) {
if (kernelFuncOp.getNumArguments() != args.size())
throw std::runtime_error("Invalid runtime arguments - kernel expected " +
std::to_string(kernelFuncOp.getNumArguments()) +
" but was provided " +
std::to_string(args.size()) + " arguments.");
inline void packArgs(OpaqueArguments &argData, py::args args,
mlir::func::FuncOp kernelFuncOp,
const std::function<bool(OpaqueArguments &argData,
py::object &arg)> &backupHandler,
bool checkNumArgs = false) {
if (checkNumArgs)
if (kernelFuncOp.getNumArguments() != args.size())
throw std::runtime_error("Invalid runtime arguments - kernel expected " +
std::to_string(kernelFuncOp.getNumArguments()) +
" but was provided " +
std::to_string(args.size()) + " arguments.");

for (std::size_t i = 0; i < args.size(); i++) {
py::object arg = args[i];
Expand Down

0 comments on commit 8764dc2

Please sign in to comment.