-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add separate function to apply shared memory indexing (#129)
This PR introduces a new function to apply shared memory indexing corrections. Previously, this was being done as part of post expansion. With the new PR, we look at the entire graph holistically and apply indexing changes to reads from shared memory. --------- Signed-off-by: Harsh Menon <harsh@nod-labs.com>
- Loading branch information
Showing
8 changed files
with
59 additions
and
38 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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,26 @@ | ||
from .._support.tracing import CapturedTrace | ||
from ..ops.wave_ops import Read, Write, get_custom | ||
from ..lang.global_symbols import * | ||
from .utils import remove_global_indexing | ||
from .constraints import Constraint, TilingConstraint | ||
import torch.fx as fx | ||
|
||
|
||
def apply_shared_memory_indexing_corrections( | ||
trace: CapturedTrace, constraints: list[Constraint] | ||
): | ||
""" | ||
This function removes global indexing from shared memory reads and writes. | ||
Global indexing is an indexing that arises from Workgroup constraints | ||
and Tiling constraints. | ||
""" | ||
tiling_constraints = [c for c in constraints if isinstance(c, TilingConstraint)] | ||
|
||
def is_shared_memory_read_or_write(node: fx.Node): | ||
custom = get_custom(node) | ||
if isinstance(custom, (Read, Write)): | ||
if custom.memory_type.address_space == SHARED_ADDRESS_SPACE: | ||
custom.index = remove_global_indexing(custom.index, tiling_constraints) | ||
return False | ||
|
||
trace.walk(is_shared_memory_read_or_write) |
This file contains 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