-
Notifications
You must be signed in to change notification settings - Fork 533
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
316 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
import torch | ||
|
||
from torch_mlir_e2e_test.torchscript.framework import TestUtils | ||
from torch_mlir_e2e_test.torchscript.registry import register_test_case | ||
from torch_mlir_e2e_test.torchscript.annotations import annotate_args, export | ||
|
||
# ============================================================================== | ||
|
||
class ArgmaxModule(torch.nn.Module): | ||
def __init__(self): | ||
super().__init__() | ||
|
||
@export | ||
@annotate_args([ | ||
None, | ||
([-1, -1], torch.float32, True), | ||
]) | ||
|
||
def forward(self, a): | ||
return torch.argmax(a) | ||
|
||
|
||
@register_test_case(module_factory=lambda: ArgmaxModule()) | ||
def ArgmaxModule_basic(module, tu: TestUtils): | ||
module.forward(tu.rand(3, 4)) | ||
|
||
# ============================================================================== | ||
|
||
class ArgmaxWithDimModule(torch.nn.Module): | ||
def __init__(self): | ||
super().__init__() | ||
|
||
@export | ||
@annotate_args([ | ||
None, | ||
([-1, -1, -1], torch.float32, True), | ||
]) | ||
def forward(self, a): | ||
return torch.argmax(a, dim=1) | ||
|
||
@register_test_case(module_factory=lambda: ArgmaxWithDimModule()) | ||
def ArgmaxModule_with_dim(module, tu: TestUtils): | ||
module.forward(tu.rand(3, 4, 5)) | ||
|
||
# ============================================================================== | ||
|
||
class ArgmaxKeepDimsModule(torch.nn.Module): | ||
def __init__(self): | ||
super().__init__() | ||
|
||
@export | ||
@annotate_args([ | ||
None, | ||
([-1, -1], torch.float32, True), | ||
]) | ||
def forward(self, a): | ||
return torch.argmax(a, 0, True) | ||
|
||
@register_test_case(module_factory=lambda: ArgmaxKeepDimsModule()) | ||
def ArgmaxModule_keepDim(module, tu: TestUtils): | ||
module.forward(tu.rand(4, 6)) | ||
|
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
Oops, something went wrong.