Skip to content

Commit

Permalink
* Python docs update (#1417)
Browse files Browse the repository at this point in the history
  • Loading branch information
khalatepradnya committed Mar 25, 2024
1 parent 4f59eb2 commit 754dac6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/sphinx/api/languages/python_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ Program Construction
.. automethod:: apply_call

.. autoclass:: cudaq::PyKernelDecorator
:members:
:special-members: __str__, __call__

.. autofunction:: kernel

Kernel Execution
=============================
Expand Down
22 changes: 20 additions & 2 deletions python/cudaq/kernel/kernel_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@ class PyKernel(object):
circuits. The :class:`Kernel` programmatically represents the circuit as an MLIR
function using the Quake dialect.
See :func:`make_kernel` for the :class:`Kernel` constructor.
Attributes:
name (:obj:`str`): The name of the :class:`Kernel` function. Read-only.
arguments (List[:class:`QuakeValue`]): The arguments accepted by the
Expand Down Expand Up @@ -1197,6 +1195,26 @@ def getListType(eleType: type):


def make_kernel(*args):
"""
Create a :class:`Kernel`: An empty kernel function to be used for quantum
program construction. This kernel is non-parameterized if it accepts no
arguments, else takes the provided types as arguments.
Returns a kernel if it is non-parameterized, else a tuple containing the
kernel and a :class:`QuakeValue` for each kernel argument.
.. code-block:: python
# Example:
# Non-parameterized kernel.
kernel = cudaq.make_kernel()
# Example:
# Parameterized kernel that accepts an `int` and `float` as arguments.
kernel, int_value, float_value = cudaq.make_kernel(int, float)
"""

kernel = PyKernel([*args])
if len([*args]) == 0:
return kernel
Expand Down

0 comments on commit 754dac6

Please sign in to comment.