-
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
7 changed files
with
273 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# 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_torchscript.e2e_test.framework import TestUtils | ||
from torch_mlir_torchscript.e2e_test.registry import register_test_case | ||
from torch_mlir_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, dim=None, keepDim=False): | ||
return torch.argmax(a, dim, keepDim) | ||
|
||
|
||
@register_test_case(module_factory=lambda: ArgmaxModule()) | ||
def ArgmaxModule_basic(module, tu: TestUtils): | ||
module.forward(tu.rand(3, 4)) | ||
|
||
@register_test_case(module_factory=lambda: ArgmaxModule()) | ||
def ArgmaxModule_with_dim(module, tu: TestUtils): | ||
module.forward(tu.rand(3, 4), dim=1, keepDim=False) | ||
|
||
@register_test_case(module_factory=lambda: ArgmaxModule()) | ||
def ArgmaxModule_keepDim(module, tu: TestUtils): | ||
module.forward(tu.rand(4, 6), dim=0, keepDim=True) |
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.