Created
December 2, 2024 23:12
-
-
Save liangfu/67fd1cbd0c2ebd5ce9a91648ffc9c246 to your computer and use it in GitHub Desktop.
Demonstrate the feasibility of combining depyf with openxla backend
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
import torch | |
import torch_xla.core.xla_model as xm | |
@torch.compile(backend="openxla") | |
def toy_example(a, b): | |
x = a / (torch.abs(a) + 1) | |
if b.sum() < 0: | |
b = b * -1 | |
return x * b | |
def main(): | |
device = xm.xla_device() | |
a = torch.randn(10).to(device=device)*10 | |
b = torch.randn(10).to(device=device)*10 | |
for _ in range(4): | |
print(toy_example(a, b).to(device="cpu")) | |
if __name__ == "__main__": | |
import depyf | |
with depyf.prepare_debug("depyf_debug_dir"): | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment