-
Notifications
You must be signed in to change notification settings - Fork 370
example: using nvrtc kernel for aot plugin #3881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/examples/dynamo/nvrtc_aot_plugin.py 2025-10-31 23:30:56.561066+00:00
+++ /home/runner/work/TensorRT/TensorRT/examples/dynamo/nvrtc_aot_plugin.py 2025-10-31 23:31:29.376720+00:00
@@ -43,11 +43,13 @@
_cuda_device = _CudaDevice()
_cuda_device.set_current()
_cuda_stream = _cuda_device.create_stream()
_program_options = _CudaProgramOptions(
- std="c++17", arch=f"sm_{_cuda_device.arch}", include_path=["/usr/local/cuda/include"]
+ std="c++17",
+ arch=f"sm_{_cuda_device.arch}",
+ include_path=["/usr/local/cuda/include"],
)
_program = _CudaProgram(cu_code, code_type="c++", options=_program_options)
_module = _program.compile("ptx", name_expressions=("pointwise_sigmoid_kernel_nvrtc",))
_kernel = _module.get_kernel("pointwise_sigmoid_kernel_nvrtc")
@@ -121,26 +123,24 @@
outputs: Tuple[trtp.TensorDesc],
) -> List[trtp.AutoTuneCombination]:
return [trtp.AutoTuneCombination("FP16, FP16", "LINEAR")]
-
@trtp.aot_impl("pointwise_sigmoid_ops::pointwise_sigmoid")
def sigmoid_aot_nvrtc_impl(
input: trtp.TensorDesc,
outputs: Tuple[trtp.TensorDesc],
tactic: int,
) -> Tuple[
Union[str, bytes], Union[str, bytes], trtp.KernelLaunchParams, trtp.SymExprs
]:
- compiled_kernel= _module.code.decode("utf-8")
+ compiled_kernel = _module.code.decode("utf-8")
print(type(compiled_kernel))
print(compiled_kernel)
# import pdb; pdb.set_trace()
-
N = input.shape_expr.numel()
launch_params = trtp.KernelLaunchParams()
block = 256
launch_params.grid_x = trtp.cdiv(N, block)67abbd5 to
0f03fb1
Compare
| print(type(compiled_kernel)) | ||
| print(compiled_kernel) | ||
|
|
||
| # import pdb; pdb.set_trace() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
|
|
||
|
|
||
| @trtp.register("pointwise_sigmoid_ops::pointwise_sigmoid") | ||
| def sigmoid_plugin_desc(input: trtp.TensorDesc) -> Tuple[trtp.TensorDesc]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we use the autogenerated registration for this?
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue)
Type of change
Please delete options that are not relevant and/or add your own.
Checklist: