Skip to content

[Enhancement] Simplify kernel source extraction in JIT adapters #230

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

Merged
merged 2 commits into from
Mar 17, 2025

Conversation

LeiWang1999
Copy link
Member

  • Updated CtypesKernelAdapter and CythonKernelAdapter to include kernel_global_source for improved source code retrieval.
  • Modified the _legalize_result_idx method in BaseKernelAdapter to accept Optional[List[int]] for better flexibility.
  • Added comments to clarify the purpose of kernel_global_source in both adapters, enhancing code readability and maintainability.

- Updated CtypesKernelAdapter and CythonKernelAdapter to include kernel_global_source for improved source code retrieval.
- Modified the _legalize_result_idx method in BaseKernelAdapter to accept Optional[List[int]] for better flexibility.
- Added comments to clarify the purpose of kernel_global_source in both adapters, enhancing code readability and maintainability.
- Changed the parameter type from List[TensorType] to List[KernelParam] in the CythonKernelAdapter's __init__ method to enhance type consistency and align with recent refactoring efforts across modules.
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR simplifies the extraction of kernel source code in the JIT adapters and makes the _legalize_result_idx interface more flexible.

  • Updates both CtypesKernelAdapter and CythonKernelAdapter to pass a pre-extracted kernel_global_source.
  • Modifies the constructor signatures and adjusts get_kernel_source methods accordingly.
  • Updates BaseKernelAdapter’s _legalize_result_idx to accept an Optional[List[int]].

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
tilelang/jit/kernel.py Extracts kernel_global_source for Ctypes and Cython backends for improved clarity.
tilelang/jit/adapter/ctypes/adapter.py Refactors constructor to receive kernel_global_source; docstring still mentions rt_mod.
tilelang/jit/adapter/cython/adapter.py Refactors constructor to receive kernel_global_source; docstring still mentions rt_mod.
tilelang/jit/adapter/base.py Updates _legalize_result_idx signature for improved flexibility.
Comments suppressed due to low confidence (2)

tilelang/jit/adapter/ctypes/adapter.py:45

  • The constructor's docstring still references 'rt_mod: Runtime module', which is no longer a parameter. Please update the docstring to reflect the new signature.
def __init__(self, params: List[TensorType], result_idx: List[int], target: str, func_or_mod: Union[tir.PrimFunc, tvm.IRModule], kernel_global_source: Optional[str] = None, verbose: bool = False, pass_configs: Optional[Dict[str, Any]] = None):

tilelang/jit/adapter/cython/adapter.py:155

  • The docstring for the constructor still includes a reference to 'rt_mod: Runtime module'. Please update the docstring to remove the outdated parameter information.
def __init__(self, params: List[KernelParam], result_idx: List[int], target: Union[str, Target], func_or_mod: Union[tir.PrimFunc, tvm.IRModule], kernel_global_source: str, verbose: bool = False, pass_configs: Optional[Dict[str, Any]] = None):

@LeiWang1999 LeiWang1999 merged commit 9ed9dfd into tile-ai:main Mar 17, 2025
3 checks passed
LeiWang1999 added a commit to LeiWang1999/tilelang that referenced this pull request Jul 18, 2025
…-ai#230)

* [Enhancement] Simplify kernel source extraction in JIT adapters

- Updated CtypesKernelAdapter and CythonKernelAdapter to include kernel_global_source for improved source code retrieval.
- Modified the _legalize_result_idx method in BaseKernelAdapter to accept Optional[List[int]] for better flexibility.
- Added comments to clarify the purpose of kernel_global_source in both adapters, enhancing code readability and maintainability.

* [Refactor] Update parameter type in CythonKernelAdapter constructor

- Changed the parameter type from List[TensorType] to List[KernelParam] in the CythonKernelAdapter's __init__ method to enhance type consistency and align with recent refactoring efforts across modules.
LeiWang1999 added a commit to LeiWang1999/tilelang that referenced this pull request Jul 18, 2025
…-ai#230)

* [Enhancement] Simplify kernel source extraction in JIT adapters

- Updated CtypesKernelAdapter and CythonKernelAdapter to include kernel_global_source for improved source code retrieval.
- Modified the _legalize_result_idx method in BaseKernelAdapter to accept Optional[List[int]] for better flexibility.
- Added comments to clarify the purpose of kernel_global_source in both adapters, enhancing code readability and maintainability.

* [Refactor] Update parameter type in CythonKernelAdapter constructor

- Changed the parameter type from List[TensorType] to List[KernelParam] in the CythonKernelAdapter's __init__ method to enhance type consistency and align with recent refactoring efforts across modules.
LeiWang1999 added a commit to LeiWang1999/tilelang that referenced this pull request Jul 18, 2025
…-ai#230)

* [Enhancement] Simplify kernel source extraction in JIT adapters

- Updated CtypesKernelAdapter and CythonKernelAdapter to include kernel_global_source for improved source code retrieval.
- Modified the _legalize_result_idx method in BaseKernelAdapter to accept Optional[List[int]] for better flexibility.
- Added comments to clarify the purpose of kernel_global_source in both adapters, enhancing code readability and maintainability.

* [Refactor] Update parameter type in CythonKernelAdapter constructor

- Changed the parameter type from List[TensorType] to List[KernelParam] in the CythonKernelAdapter's __init__ method to enhance type consistency and align with recent refactoring efforts across modules.
LeiWang1999 added a commit to LeiWang1999/tilelang that referenced this pull request Jul 20, 2025
…-ai#230)

* [Enhancement] Simplify kernel source extraction in JIT adapters

- Updated CtypesKernelAdapter and CythonKernelAdapter to include kernel_global_source for improved source code retrieval.
- Modified the _legalize_result_idx method in BaseKernelAdapter to accept Optional[List[int]] for better flexibility.
- Added comments to clarify the purpose of kernel_global_source in both adapters, enhancing code readability and maintainability.

* [Refactor] Update parameter type in CythonKernelAdapter constructor

- Changed the parameter type from List[TensorType] to List[KernelParam] in the CythonKernelAdapter's __init__ method to enhance type consistency and align with recent refactoring efforts across modules.
LeiWang1999 added a commit to LeiWang1999/tilelang that referenced this pull request Jul 20, 2025
…-ai#230)

* [Enhancement] Simplify kernel source extraction in JIT adapters

- Updated CtypesKernelAdapter and CythonKernelAdapter to include kernel_global_source for improved source code retrieval.
- Modified the _legalize_result_idx method in BaseKernelAdapter to accept Optional[List[int]] for better flexibility.
- Added comments to clarify the purpose of kernel_global_source in both adapters, enhancing code readability and maintainability.

* [Refactor] Update parameter type in CythonKernelAdapter constructor

- Changed the parameter type from List[TensorType] to List[KernelParam] in the CythonKernelAdapter's __init__ method to enhance type consistency and align with recent refactoring efforts across modules.
LeiWang1999 added a commit to LeiWang1999/tilelang that referenced this pull request Jul 20, 2025
…-ai#230)

* [Enhancement] Simplify kernel source extraction in JIT adapters

- Updated CtypesKernelAdapter and CythonKernelAdapter to include kernel_global_source for improved source code retrieval.
- Modified the _legalize_result_idx method in BaseKernelAdapter to accept Optional[List[int]] for better flexibility.
- Added comments to clarify the purpose of kernel_global_source in both adapters, enhancing code readability and maintainability.

* [Refactor] Update parameter type in CythonKernelAdapter constructor

- Changed the parameter type from List[TensorType] to List[KernelParam] in the CythonKernelAdapter's __init__ method to enhance type consistency and align with recent refactoring efforts across modules.
LeiWang1999 added a commit to LeiWang1999/tilelang that referenced this pull request Jul 20, 2025
…-ai#230)

* [Enhancement] Simplify kernel source extraction in JIT adapters

- Updated CtypesKernelAdapter and CythonKernelAdapter to include kernel_global_source for improved source code retrieval.
- Modified the _legalize_result_idx method in BaseKernelAdapter to accept Optional[List[int]] for better flexibility.
- Added comments to clarify the purpose of kernel_global_source in both adapters, enhancing code readability and maintainability.

* [Refactor] Update parameter type in CythonKernelAdapter constructor

- Changed the parameter type from List[TensorType] to List[KernelParam] in the CythonKernelAdapter's __init__ method to enhance type consistency and align with recent refactoring efforts across modules.
LeiWang1999 added a commit to LeiWang1999/tilelang that referenced this pull request Jul 20, 2025
…-ai#230)

* [Enhancement] Simplify kernel source extraction in JIT adapters

- Updated CtypesKernelAdapter and CythonKernelAdapter to include kernel_global_source for improved source code retrieval.
- Modified the _legalize_result_idx method in BaseKernelAdapter to accept Optional[List[int]] for better flexibility.
- Added comments to clarify the purpose of kernel_global_source in both adapters, enhancing code readability and maintainability.

* [Refactor] Update parameter type in CythonKernelAdapter constructor

- Changed the parameter type from List[TensorType] to List[KernelParam] in the CythonKernelAdapter's __init__ method to enhance type consistency and align with recent refactoring efforts across modules.
LeiWang1999 added a commit to LeiWang1999/tilelang that referenced this pull request Jul 20, 2025
…-ai#230)

* [Enhancement] Simplify kernel source extraction in JIT adapters

- Updated CtypesKernelAdapter and CythonKernelAdapter to include kernel_global_source for improved source code retrieval.
- Modified the _legalize_result_idx method in BaseKernelAdapter to accept Optional[List[int]] for better flexibility.
- Added comments to clarify the purpose of kernel_global_source in both adapters, enhancing code readability and maintainability.

* [Refactor] Update parameter type in CythonKernelAdapter constructor

- Changed the parameter type from List[TensorType] to List[KernelParam] in the CythonKernelAdapter's __init__ method to enhance type consistency and align with recent refactoring efforts across modules.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant