-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 03bedd4 [compiler] support splat value in CompareFolder (#294) - c34abdc [compiler] fix bug in RemoveCopy (#289) - b1914a7 [dynamo] byteir dynamo backend (#291) GitOrigin-RevId: 03bedd4
- Loading branch information
Showing
19 changed files
with
2,528 additions
and
45 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
38 changes: 38 additions & 0 deletions
38
...ds/torch-frontend/torch-frontend/python/torch_frontend/byteir_backend/README.md
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,38 @@ | ||
*Requires torch version 2.4 or higher* | ||
|
||
- Usage | ||
|
||
```python | ||
import torch | ||
|
||
import torch_frontend | ||
from torch_frontend import byteir_backend as byteir_backend | ||
from torch_frontend.byteir_backend.utils import * | ||
|
||
class NaiveModel(torch.nn.Module): | ||
def __init__(self): | ||
super().__init__() | ||
def forward(self, x0, x1, x2): | ||
r0 = torch.ops.aten.mul(x0, x1) | ||
r1 = torch.ops.aten.div(r0, x2) | ||
x0 = torch.ops.aten.mul(r1, r1) - x0 | ||
r2 = torch.ops.aten.slice(x0, 1, 1, 3, 1) | ||
return r1, r2 | ||
|
||
model = NaiveModel() | ||
opt_mod = torch.compile(model, backend="byteir") | ||
|
||
x0 = torch.rand(32, 64).to('cuda') | ||
x1 = torch.rand(32, 64).to('cuda') | ||
x2 = torch.rand(32, 64).to('cuda') | ||
|
||
x0 = x0.as_strided(size=(32,16), stride=(64,2), storage_offset=16) | ||
x1 = x1.as_strided(size=(32,16), stride=(64,1), storage_offset=8) | ||
x2 = x2.as_strided(size=(32,16), stride=(32,1), storage_offset=32) | ||
|
||
golden = model(x0, x1, x2) | ||
outs = opt_mod(x0, x1, x2) | ||
torch.cuda.synchronize() | ||
|
||
torch.testing.assert_close(golden, outs) | ||
``` |
13 changes: 13 additions & 0 deletions
13
frontends/torch-frontend/torch-frontend/python/torch_frontend/byteir_backend/__init__.py
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,13 @@ | ||
from torch._dynamo import register_backend | ||
|
||
|
||
@register_backend | ||
def byteir(*args, **kwargs): | ||
from .compiler import byteir_compiler | ||
|
||
return byteir_compiler(*args, **kwargs) | ||
|
||
def set_cache_dir(path: str): | ||
from .compilation_cache import ByteIRFxGraphCache | ||
|
||
ByteIRFxGraphCache.base_cache_dir = path |
Oops, something went wrong.