rocm.bindings.hiprtc#

2026-09-24

12 min read time

Applies to Linux and Windows

Advanced Micro Devices, Inc.

Attributes#

Classes#

hiprtcResult

ihiprtcLinkState

(No short description)

Functions#

has_symbol(→ bool)

hiprtcGetErrorString(result)

Returns text string message to explain the error which occurred

hiprtcVersion()

Sets the parameters as major and minor version.

hiprtcAddNameExpression(prog, name_expression)

Adds the given name exprssion to the runtime compilation program.

hiprtcCompileProgram(prog, numOptions, options)

Compiles the given runtime compilation program.

hiprtcCreateProgram(src, name, numHeaders, headers, ...)

Creates an instance of hiprtcProgram with the given input parameters,

hiprtcDestroyProgram(prog)

Destroys an instance of given hiprtcProgram.

hiprtcGetLoweredName(prog, name_expression)

Gets the lowered (mangled) name from an instance of hiprtcProgram with the given input

hiprtcGetProgramLog(prog, log)

Gets the log generated by the runtime compilation program instance.

hiprtcGetProgramLogSize(prog)

Gets the size of log generated by the runtime compilation program instance.

hiprtcGetCode(prog, code)

Gets the pointer of compilation binary by the runtime compilation program instance.

hiprtcGetCodeSize(prog)

Gets the size of compilation binary by the runtime compilation program instance.

hiprtcGetBitcode(prog, bitcode)

Gets the pointer of compiled bitcode by the runtime compilation program instance.

hiprtcGetBitcodeSize(prog)

Gets the size of compiled bitcode by the runtime compilation program instance.

hiprtcLinkCreate(num_options, option_ptr, option_vals_pptr)

Creates the link instance via hiprtc APIs.

hiprtcLinkAddFile(hip_link_state, input_type, ...)

Adds a file with bit code to be linked with options

hiprtcLinkAddData(hip_link_state, input_type, image, ...)

Completes the linking of the given program.

hiprtcLinkComplete(hip_link_state)

Completes the linking of the given program.

hiprtcLinkDestroy(hip_link_state)

Deletes the link instance via hiprtc APIs.

Module Contents#

rocm.bindings.hiprtc.has_symbol(name: str | bytes | bytearray) → bool#
class rocm.bindings.hiprtc.hiprtcResult#

Bases: enum.IntEnum

hiprtc error code

HIPRTC_SUCCESS: int#
HIPRTC_ERROR_OUT_OF_MEMORY: int#
HIPRTC_ERROR_PROGRAM_CREATION_FAILURE: int#
HIPRTC_ERROR_INVALID_INPUT: int#
HIPRTC_ERROR_INVALID_PROGRAM: int#
HIPRTC_ERROR_INVALID_OPTION: int#
HIPRTC_ERROR_COMPILATION: int#
HIPRTC_ERROR_BUILTIN_OPERATION_FAILURE: int#
HIPRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION: int#
HIPRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION: int#
HIPRTC_ERROR_NAME_EXPRESSION_NOT_VALID: int#
HIPRTC_ERROR_INTERNAL_ERROR: int#
HIPRTC_ERROR_LINKING: int#
class rocm.bindings.hiprtc.ihiprtcLinkState(*args, **kwargs)#

Bases: rocm.bindings.util.types.Pointer

(No short description)

rocm.bindings.hiprtc.hiprtcLinkState#
rocm.bindings.hiprtc.hiprtcGetErrorString(result)#

Returns text string message to explain the error which occurred

Warning:

In HIP, this function returns the name of the error, if the hiprtc result is defined, it will return “Invalid HIPRTC error code”

See:

hiprtcResult

Args:
result (hiprtcResult) – IN:

code to convert to string.

Returns:

A tuple of size 2 that contains (in that order):

C signature

const char * hiprtcGetErrorString(hiprtcResult result)
rocm.bindings.hiprtc.hiprtcVersion()#

Sets the parameters as major and minor version.

Returns:

A tuple of size 3 that contains (in that order):

C signature

hiprtcResult hiprtcVersion(int * major, int * minor)
rocm.bindings.hiprtc.hiprtcProgram#
rocm.bindings.hiprtc.hiprtcAddNameExpression(prog, name_expression)#

Adds the given name exprssion to the runtime compilation program.

If const char pointer is NULL, it will return HIPRTC_ERROR_INVALID_INPUT.

See:

hiprtcResult

Args:
prog (_hiprtcProgram/object) – IN:

runtime compilation program instance.

name_expression (CStr/object) – IN:

const char pointer to the name expression.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hiprtcResult hiprtcAddNameExpression(hiprtcProgram prog, const char * name_expression)
rocm.bindings.hiprtc.hiprtcCompileProgram(prog, numOptions, options)#

Compiles the given runtime compilation program.

If the compiler failed to build the runtime compilation program, it will return HIPRTC_ERROR_COMPILATION.

See:

hiprtcResult

Args:
prog (_hiprtcProgram/object) – IN:

runtime compilation program instance.

numOptions (int) – IN:

number of compiler options.

options (ListOfBytes/object) – IN:

compiler options as const array of strins.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hiprtcResult hiprtcCompileProgram(hiprtcProgram prog, int numOptions, const char *const * options)
rocm.bindings.hiprtc.hiprtcCreateProgram(src, name, numHeaders, headers, includeNames)#

Creates an instance of hiprtcProgram with the given input parameters, and sets the output hiprtcProgram prog with it.

Any invalide input parameter, it will return HIPRTC_ERROR_INVALID_INPUT or HIPRTC_ERROR_INVALID_PROGRAM.

If failed to create the program, it will return HIPRTC_ERROR_PROGRAM_CREATION_FAILURE.

See:

hiprtcResult

Args:
src (CStr/object) – IN:

const char pointer to the program source.

name (CStr/object) – IN:

const char pointer to the program name.

numHeaders (int) – IN:

number of headers.

headers (ListOfBytes/object) – IN:

array of strings pointing to headers.

includeNames (ListOfBytes/object) – IN:

array of strings pointing to names included in program source.

Returns:

A tuple of size 2 that contains (in that order):

C signature

hiprtcResult hiprtcCreateProgram(hiprtcProgram * prog, const char * src, const char * name, int numHeaders, const char *const * headers, const char *const * includeNames)
rocm.bindings.hiprtc.hiprtcDestroyProgram(prog)#

Destroys an instance of given hiprtcProgram.

If prog is NULL, it will return HIPRTC_ERROR_INVALID_INPUT.

See:

hiprtcResult

Args:
prog (Pointer/object) – IN:

runtime compilation program instance.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hiprtcResult hiprtcDestroyProgram(hiprtcProgram * prog)
rocm.bindings.hiprtc.hiprtcGetLoweredName(prog, name_expression)#

Gets the lowered (mangled) name from an instance of hiprtcProgram with the given input parameters, and sets the output lowered_name with it.

If any invalide nullptr input parameters, it will return HIPRTC_ERROR_INVALID_INPUT

If name_expression is not found, it will return HIPRTC_ERROR_NAME_EXPRESSION_NOT_VALID

If failed to get lowered_name from the program, it will return HIPRTC_ERROR_COMPILATION.

See:

hiprtcResult

Args:
prog (_hiprtcProgram/object) – IN:

runtime compilation program instance.

name_expression (CStr/object) – IN:

const char pointer to the name expression.

Returns:

A tuple of size 2 that contains (in that order):

C signature

hiprtcResult hiprtcGetLoweredName(hiprtcProgram prog, const char * name_expression, const char ** lowered_name)
rocm.bindings.hiprtc.hiprtcGetProgramLog(prog, log)#

Gets the log generated by the runtime compilation program instance.

See:

hiprtcResult

Args:
prog (_hiprtcProgram/object) – IN:

runtime compilation program instance.

log (CStr/object) – OUT:

memory pointer to the generated log.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hiprtcResult hiprtcGetProgramLog(hiprtcProgram prog, char * log)
rocm.bindings.hiprtc.hiprtcGetProgramLogSize(prog)#

Gets the size of log generated by the runtime compilation program instance.

See:

hiprtcResult

Args:
prog (_hiprtcProgram/object) – IN:

runtime compilation program instance.

Returns:

A tuple of size 2 that contains (in that order):

C signature

hiprtcResult hiprtcGetProgramLogSize(hiprtcProgram prog, size_t * logSizeRet)
rocm.bindings.hiprtc.hiprtcGetCode(prog, code)#

Gets the pointer of compilation binary by the runtime compilation program instance.

See:

hiprtcResult

Args:
prog (_hiprtcProgram/object) – IN:

runtime compilation program instance.

code (NDBuffer/object) – OUT:

char pointer to binary.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hiprtcResult hiprtcGetCode(hiprtcProgram prog, char * code)
rocm.bindings.hiprtc.hiprtcGetCodeSize(prog)#

Gets the size of compilation binary by the runtime compilation program instance.

See:

hiprtcResult

Args:
prog (_hiprtcProgram/object) – IN:

runtime compilation program instance.

Returns:

A tuple of size 2 that contains (in that order):

C signature

hiprtcResult hiprtcGetCodeSize(hiprtcProgram prog, size_t * codeSizeRet)
rocm.bindings.hiprtc.hiprtcGetBitcode(prog, bitcode)#

Gets the pointer of compiled bitcode by the runtime compilation program instance.

See:

hiprtcResult

Args:
prog (_hiprtcProgram/object) – IN:

runtime compilation program instance.

bitcode (NDBuffer/object) – OUT:

char pointer to bitcode.

Returns:

A tuple of size 1 that contains (in that order):

C signature

hiprtcResult hiprtcGetBitcode(hiprtcProgram prog, char * bitcode)
rocm.bindings.hiprtc.hiprtcGetBitcodeSize(prog)#

Gets the size of compiled bitcode by the runtime compilation program instance.

See:

hiprtcResult

Args:
prog (_hiprtcProgram/object) – IN:

runtime compilation program instance.

Returns:

A tuple of size 2 that contains (in that order):

C signature

hiprtcResult hiprtcGetBitcodeSize(hiprtcProgram prog, size_t * bitcode_size)
rocm.bindings.hiprtc.hiprtcLinkCreate(num_options, option_ptr, option_vals_pptr)#

Creates the link instance via hiprtc APIs.

See:

hiprtcResult

Args:
num_options (int) – IN:

Number of options

option_ptr (HiprtcLinkCreate_option_ptr/object) – IN:

Array of options

option_vals_pptr (ListOfPointer/object) – IN:

Array of option values cast to void*

Returns:

A tuple of size 2 that contains (in that order):

C signature

hiprtcResult hiprtcLinkCreate(unsigned int num_options, hipJitOption * option_ptr, void ** option_vals_pptr, hiprtcLinkState * hip_link_state_ptr)
rocm.bindings.hiprtc.hiprtcLinkAddFile(hip_link_state, input_type, file_path, num_options, options_ptr, option_values)#

Adds a file with bit code to be linked with options

If input values are invalid, it will

See:

hiprtcResult

Args:
hip_link_state (ihiprtcLinkState/object) – IN:

hiprtc link state

input_type (hipJitInputType) – IN:

Type of the input data or bitcode

file_path (CStr/object) – IN:

Path to the input file where bitcode is present

num_options (int) – IN:

Size of the options

options_ptr (Pointer/object) – IN:

Array of options applied to this input

option_values (ListOfPointer/object) – IN:

Array of option values cast to void*

Returns:

A tuple of size 1 that contains (in that order):

C signature

hiprtcResult hiprtcLinkAddFile(hiprtcLinkState hip_link_state, hipJitInputType input_type, const char * file_path, unsigned int num_options, hipJitOption * options_ptr, void ** option_values)
rocm.bindings.hiprtc.hiprtcLinkAddData(hip_link_state, input_type, image, image_size, name, num_options, options_ptr, option_values)#

Completes the linking of the given program.

If adding the file fails, it will

See:

hiprtcResult

Args:
hip_link_state (ihiprtcLinkState/object) – IN:

hiprtc link state

input_type (hipJitInputType) – IN:

Type of the input data or bitcode

image (Pointer/object) – IN:

Input data which is null terminated

image_size (int) – IN:

Size of the input data

name (CStr/object) – IN:

Optional name for this input

num_options (int) – IN:

Size of the options

options_ptr (Pointer/object) – IN:

Array of options applied to this input

option_values (ListOfPointer/object) – IN:

Array of option values cast to void*

Returns:

A tuple of size 1 that contains (in that order):

C signature

hiprtcResult hiprtcLinkAddData(hiprtcLinkState hip_link_state, hipJitInputType input_type, void * image, size_t image_size, const char * name, unsigned int num_options, hipJitOption * options_ptr, void ** option_values)
rocm.bindings.hiprtc.hiprtcLinkComplete(hip_link_state)#

Completes the linking of the given program.

If adding the data fails, it will

See:

hiprtcResult

Args:
hip_link_state (ihiprtcLinkState/object) – IN:

hiprtc link state

Returns:

A tuple of size 3 that contains (in that order):

C signature

hiprtcResult hiprtcLinkComplete(hiprtcLinkState hip_link_state, void ** bin_out, size_t * size_out)
rocm.bindings.hiprtc.hiprtcLinkDestroy(hip_link_state)#

Deletes the link instance via hiprtc APIs.

See:

hiprtcResult

Args:
hip_link_state (ihiprtcLinkState/object) – IN:

link state instance

Returns:

A tuple of size 1 that contains (in that order):

C signature

hiprtcResult hiprtcLinkDestroy(hiprtcLinkState hip_link_state)