-
Notifications
You must be signed in to change notification settings - Fork 326
[Feat] Add support for T.serial with step and negative step
#1188
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
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5a6204e
[Feature] Support serial for with step
kurisu6912 8fe6fc2
add more tests
kurisu6912 328bf52
Merge branch 'main' of https://github.com/tile-ai/tilelang into patch…
Hamerlate c7c9a49
fix
Hamerlate ff229bd
Enhance trip count validation in SerialForWithStep to ensure non-zero…
Hamerlate 3d10d99
Update builder.py
LeiWang1999 54f2da3
fix lint error
kurisu6912 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| """The language interface for tl programs.""" | ||
| from __future__ import annotations | ||
|
|
||
| from typing import Any | ||
| from tvm import tir | ||
| from tvm.tir import IntImm | ||
| import tvm.script.ir_builder.tir as tb_tir | ||
| from .v2.builder import SerialForWithStep | ||
| from tilelang import _ffi_api | ||
|
|
||
|
|
||
| def Parallel(*extents: tir.PrimExpr, coalesced_width: int | None = None): | ||
| """Tools to construct nested parallel for loop. | ||
| This can be used to create element-wise tensor expression. | ||
| Parameters | ||
| ---------- | ||
| extents : PrimExpr | ||
| The extents of the iteration. | ||
| coalesced_width : Optional[int] | ||
| The coalesced width of the parallel loop. | ||
| Returns | ||
| ------- | ||
| res : frame.ForFrame | ||
| The ForFrame. | ||
| """ | ||
| annotations: dict[str, Any] = {} | ||
| if coalesced_width is not None: | ||
| annotations.update({"coalesced_width": coalesced_width}) | ||
| return _ffi_api.Parallel(extents, annotations) # type: ignore[attr-defined] # pylint: disable=no-member | ||
|
|
||
|
|
||
| def Persistent( | ||
| domain: list[tir.PrimExpr], | ||
| wave_size: tir.PrimExpr, | ||
| index: tir.PrimExpr, | ||
| group_size: tir.PrimExpr | None = 8, | ||
| ): | ||
| """Tools to construct persistent for loop. | ||
| Parameters | ||
| ---------- | ||
| domain : List[tir.PrimExpr] | ||
| The list of dominators. | ||
| wave_size : int | ||
| The wave size. | ||
| index : int | ||
| The tile index in one wave. | ||
| group_size : tir.PrimExpr | ||
| The group size. | ||
| """ | ||
| return _ffi_api.Persistent(domain, wave_size, index, group_size) | ||
|
|
||
|
|
||
| def Pipelined( | ||
| start: tir.PrimExpr, | ||
| stop: tir.PrimExpr = None, | ||
| num_stages: int = 0, | ||
| order: list[int] | None = None, | ||
| stage: list[int] | None = None, | ||
| sync: list[list[int]] | None = None, | ||
| group: list[list[int]] | None = None, | ||
| ): | ||
| """Tools to construct pipelined for loop. | ||
| Parameters | ||
| ---------- | ||
| start : PrimExpr | ||
| The minimum value of iteration. | ||
| stop : PrimExpr | ||
| The maximum value of iteration. | ||
| num_stages : int | ||
| The max number of buffer used between pipeline producers and consumers. | ||
| if num_stages is 0, pipeline will not be enabled. | ||
| Returns | ||
| ------- | ||
| res : frame.ForFrame | ||
| The ForFrame. | ||
| """ | ||
| if stop is None: | ||
| stop = start | ||
| start = IntImm(start.dtype, 0) if hasattr(start, "dtype") else 0 | ||
| if order is None: | ||
| order = [] | ||
| if stage is None: | ||
| stage = [] | ||
| if sync is None: | ||
| sync = [] | ||
| if group is None: | ||
| group = [] | ||
| # type: ignore[attr-defined] # pylint: disable=no-member | ||
| return _ffi_api.Pipelined(start, stop, num_stages, order, stage, sync, group) | ||
|
|
||
|
|
||
| def serial(start: tir.PrimExpr, | ||
| stop: tir.PrimExpr | None = None, | ||
| step: tir.PrimExpr | None = None, | ||
| *, | ||
| annotations: dict[str, Any] | None = None): | ||
| if step is None or step == 1: | ||
| return tb_tir.serial(start, stop, annotations=annotations) | ||
| else: | ||
| if stop is None: | ||
| stop = start | ||
| start = IntImm(start.dtype, 0) if hasattr(start, "dtype") else 0 | ||
| return SerialForWithStep(start, stop, step, annotations=annotations) | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.