-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
14 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
import torch | ||
from torch._dynamo.backends.common import aot_autograd | ||
from torch._functorch._aot_autograd.utils import make_boxed_compiler | ||
from torch._functorch.aot_autograd import make_boxed_compiler | ||
|
||
from plai.pl_torch_compiler import dummy_compiler, dump_compiler, plnn_compiler | ||
from tests.module_pool.simple_nn import SimpleNN, check_torch_compile_forward, check_torch_compile_backward | ||
from plai.pl_torch_compiler import plnn_compiler | ||
|
||
|
||
def test_torch_plnn_compile_mutiple_output(): | ||
model = lambda x: torch.max(x, dim=0)[0] | ||
def test_torch_plnn_compile_multiple_output(): | ||
model = (lambda x: torch.max(x, dim=0)) | ||
custom_compiler = plnn_compiler.CustomCompiler() | ||
aot_backend = aot_autograd(fw_compiler=make_boxed_compiler(custom_compiler), bw_compiler=None) | ||
aot_backend = aot_autograd(fw_compiler=make_boxed_compiler(custom_compiler)) | ||
compiled_model = torch.compile(model, backend=aot_backend) | ||
check_torch_compile_forward(model, compiled_model) | ||
input_data = torch.randn(1, 10) | ||
expected_output = model(input_data) | ||
actual_output = compiled_model(input_data) | ||
assert torch.allclose(expected_output.values, actual_output.values) | ||
assert torch.allclose(expected_output.indices, actual_output.indices) | ||
print('dump compile forward:') | ||
print(custom_compiler.graph) |