Skip to content

Make the ObjectCode class lazy load modules #268

Description

@keenan-simpson

Currently this is executed at construction time:

ifisinstance(module, str):
# TODO: this option is only taken by the new library APIs, but we have# a bug that we can't easily support it just yet (NVIDIA/cuda-python#73).ifjit_optionsisnotNone:
raiseValueErrormodule=module.encode()
self._handle=handle_return(self._loader["file"](module))
else:
assertisinstance(module, bytes)
ifjit_optionsisNone:
jit_options= {}
ifbackend=="new":
args= (
module,
list(jit_options.keys()),
list(jit_options.values()),
len(jit_options),
# TODO: support library options
[],
[],
0,
)
else: # "old" backendargs= (module, len(jit_options), list(jit_options.keys()), list(jit_options.values()))
self._handle=handle_return(self._loader["data"](*args))

This should happen in a lazy_load method. Certain uses of the ObjectCode object don't require the module to be loaded, such as linking ptx or ltoir code objects together.

Metadata

Metadata

Labels

P1Medium priority - Should docuda.coreEverything related to the cuda.core moduleenhancementAny code-related improvements

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions