-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a second gridsampler testcase to test both align_corners modes (#…
…178) gridsampler has a parameter to select how corners and edges are aligned. The two options are now implemented and therefore two cases are provided with this PR.
- Loading branch information
1 parent
1d77dcf
commit a6c84bd
Showing
2 changed files
with
45 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright 2024 Advanced Micro Devices, Inc. | ||
# | ||
# Licensed 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 sys, argparse | ||
import torch | ||
import torch.nn as nn | ||
import torch_mlir | ||
|
||
# import from e2eshark/tools to allow running in current dir, for run through | ||
# run.pl, commutils is symbolically linked to allow any rundir to work | ||
sys.path.insert(0, "../../../tools/stubs") | ||
from commonutils import E2ESHARK_CHECK_DEF | ||
|
||
# Create an instance of it for this test | ||
E2ESHARK_CHECK = dict(E2ESHARK_CHECK_DEF) | ||
|
||
class op_gridsampler(nn.Module): | ||
def __init__(self): | ||
super().__init__() | ||
|
||
def forward(self, x, g): | ||
z = nn.functional.grid_sample(x, g, mode="bilinear", padding_mode="zeros", align_corners=True) | ||
return z | ||
|
||
model = op_gridsampler() | ||
torch.manual_seed(42) | ||
X = torch.rand(4, 7, 8, 11) | ||
Y = torch.rand(4, 9, 13, 2)*2-1 | ||
Z = model(X, Y) | ||
|
||
E2ESHARK_CHECK["input"] = [X, Y] | ||
E2ESHARK_CHECK["output"] = Z | ||
print("Input:", X) | ||
print("Grid:", Y) | ||
print("Output:", Z) |