legate.core.task.task#
- legate.core.task.task(
- func: UserFunction | None = None,
- *,
- tuple variants: tuple[VariantCode,
- ...] = DEFAULT_VARIANT_LIST,
- constraints: Sequence[DeferredConstraint] | None = None,
- bool throws_exception: bool = False,
- bool has_side_effect: bool = False,
- bool register: bool = True,
Convert a Python function to a Legate task.
- Parameters:
func (UserFunction) – The base user function to invoke in the task.
variants (tuple[VariantCode, ...], optional) – The list of variants for which
func
is applicable. Defaults to(<VariantCode.CPU: 1>,)
.constraints (Sequence[DeferredConstraint], optional) – The list of constraints which are to be applied to the arguments of
func
, if any. Defaults to no constraints.throws_exception (bool, False) – True if any variants of
func
throws an exception, False otherwise.has_side_effect (bool, False) – Whether the task has any global side-effects. See
AutoTask.set_side_ effect()
for further information.register (bool, True) – Whether to immediately complete registration of the task. Deferring registration is used to add additional variants to the task that have a different body. However, all variants must have identical signatures. The user must manually call
PyTask.complete_registration
to finish registering the task.
- Returns:
The task object.
- Return type:
Example
from legate.core import broadcast, align, VariantCode from legate.core.task import task, InputArray, OutputArray @task def my_basic_task( x: InputArray, y: OutputArray, z: tuple[int, ...] = (1, 2, 3) ) -> None: ... @task( variants=(VariantCode.CPU, VariantCode.GPU), constraints=(align("x", "y"), broadcast("x")), throws_exception=True, ) def my_task_with_options( x: InputArray, y: OutputArray, z: tuple[int, ...] = (1, 2, 3) ) -> None: raise RuntimeError("Exceptional!")
See also
legate.core.task.task.PyTask.__init__