IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: Nightly
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

current_accelerator

def current_accelerator() -> CompilationTarget

Get the current compilation target, which must be an accelerator.

This function returns a value identical to CompilationTarget.current(), but will error during compilation if the current target is not an accelerator.

This function is expected to only be called within an offload compilation (compile_info).

Prefer this function over default_accelerator() when used in Mojo code intended only for use on an accelerators, such as kernel implementations. Code that may run in host elaboration context should avoid this function.

Constraints:

The compilation target of the current compilation context must be an accelerator target.

Returns:

CompilationTarget: A value representing the current accelerator target.