cuda.core.ObjectCode#
- class cuda.core.ObjectCode(*args, **kwargs)#
Represent a compiled program to be loaded onto the device.
This object provides a unified interface for different types of compiled programs that will be loaded onto the device.
Note
This class has no default constructor. If you already have a cubin that you would like to load, use the
from_cubin()alternative constructor. Constructing directly from all other possible code types should be avoided in favor of compilation throughProgramMethods
- __init__(*args, **kwargs)#
- static from_cubin(
- module: bytes | str,
- *,
- str name: str = '',
- dict symbol_mapping: dict | None = None,
Create an
ObjectCodeinstance from an existing cubin.- Parameters:
module (Union[bytes, str]) – Either a bytes object containing the in-memory cubin to load, or a file path string pointing to the on-disk cubin to load.
name (Optional[str]) – A human-readable identifier representing this code object.
symbol_mapping (Optional[dict]) – A dictionary specifying how the unmangled symbol names (as keys) should be mapped to the mangled names before trying to retrieve them (default to no mappings).
- static from_fatbin(
- module: bytes | str,
- *,
- str name: str = '',
- dict symbol_mapping: dict | None = None,
Create an
ObjectCodeinstance from an existing fatbin.- Parameters:
module (Union[bytes, str]) – Either a bytes object containing the in-memory fatbin to load, or a file path string pointing to the on-disk fatbin to load.
name (Optional[str]) – A human-readable identifier representing this code object.
symbol_mapping (Optional[dict]) – A dictionary specifying how the unmangled symbol names (as keys) should be mapped to the mangled names before trying to retrieve them (default to no mappings).
- static from_library(
- module: bytes | str,
- *,
- str name: str = '',
- dict symbol_mapping: dict | None = None,
Create an
ObjectCodeinstance from an existing library.- Parameters:
module (Union[bytes, str]) – Either a bytes object containing the in-memory library to load, or a file path string pointing to the on-disk library to load.
name (Optional[str]) – A human-readable identifier representing this code object.
symbol_mapping (Optional[dict]) – A dictionary specifying how the unmangled symbol names (as keys) should be mapped to the mangled names before trying to retrieve them (default to no mappings).
- static from_ltoir(
- module: bytes | str,
- *,
- str name: str = '',
- dict symbol_mapping: dict | None = None,
Create an
ObjectCodeinstance from an existing LTOIR.- Parameters:
module (Union[bytes, str]) – Either a bytes object containing the in-memory ltoir code to load, or a file path string pointing to the on-disk ltoir file to load.
name (Optional[str]) – A human-readable identifier representing this code object.
symbol_mapping (Optional[dict]) – A dictionary specifying how the unmangled symbol names (as keys) should be mapped to the mangled names before trying to retrieve them (default to no mappings).
- static from_object(
- module: bytes | str,
- *,
- str name: str = '',
- dict symbol_mapping: dict | None = None,
Create an
ObjectCodeinstance from an existing object code.- Parameters:
module (Union[bytes, str]) – Either a bytes object containing the in-memory object code to load, or a file path string pointing to the on-disk object code to load.
name (Optional[str]) – A human-readable identifier representing this code object.
symbol_mapping (Optional[dict]) – A dictionary specifying how the unmangled symbol names (as keys) should be mapped to the mangled names before trying to retrieve them (default to no mappings).
- static from_ptx(
- module: bytes | str,
- *,
- str name: str = '',
- dict symbol_mapping: dict | None = None,
Create an
ObjectCodeinstance from an existing PTX.- Parameters:
module (Union[bytes, str]) – Either a bytes object containing the in-memory ptx code to load, or a file path string pointing to the on-disk ptx file to load.
name (Optional[str]) – A human-readable identifier representing this code object.
symbol_mapping (Optional[dict]) – A dictionary specifying how the unmangled symbol names (as keys) should be mapped to the mangled names before trying to retrieve them (default to no mappings).
Attributes
- code#
CodeTypeT
Return the underlying code object.
- Type:
ObjectCode.code
- code_type#
str
Return the type of the underlying code object.
- Type:
ObjectCode.code_type
- handle#
Return the underlying handle object.
Caution
This handle is a Python object. To get the memory address of the underlying C handle, call
int(ObjectCode.handle).
- name#
str
Return a human-readable name of this code object.
- Type:
ObjectCode.name
- symbol_mapping#
dict
Return a copy of the symbol mapping dictionary.
- Type:
ObjectCode.symbol_mapping