forked from openvinotoolkit/openvino
-
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.
Merge pull request openvinotoolkit#67 from bszmelcz/add_aten_adaptive…
…_maxpool2d Add aten adaptive maxpool2d
- Loading branch information
Showing
2 changed files
with
53 additions
and
7 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
51 changes: 51 additions & 0 deletions
51
tests/layer_tests/pytorch_tests/test_adaptive_max_pool_2d.py
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,51 @@ | ||
# Copyright (C) 2018-2022 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import pytest | ||
from pytorch_layer_test_class import PytorchLayerTest | ||
import numpy as np | ||
import torch | ||
import torch.nn as nn | ||
import torch.nn.functional as F | ||
|
||
|
||
class TestAdaptiveMaxPool2D(PytorchLayerTest): | ||
|
||
def _prepare_input(self): | ||
return (self.input_tensor,) | ||
|
||
def create_model(self, output_size=None, return_indices=False): | ||
|
||
class aten_adaptive_max_pool2d(torch.nn.Module): | ||
|
||
def __init__(self, output_size=None, return_indices=False) -> None: | ||
super().__init__() | ||
self.output_size = output_size | ||
self.return_indices = return_indices | ||
|
||
def forward(self, input_tensor): | ||
if self.return_indices: | ||
output, indices = F.adaptive_max_pool2d(input_tensor, self.output_size, True) | ||
return output | ||
return F.adaptive_max_pool2d(input_tensor, self.output_size, False) | ||
|
||
ref_net = None | ||
|
||
return aten_adaptive_max_pool2d(output_size, return_indices), ref_net, "aten::adaptive_max_pool2d" | ||
|
||
@pytest.mark.parametrize('input_tensor', ([ | ||
np.random.randn(1, 1, 4, 4).astype(np.float32), | ||
np.random.randn(1, 3, 32, 32).astype(np.float32) | ||
])) | ||
@pytest.mark.parametrize('output_size', ([ | ||
[2, 2], | ||
[4, 4], | ||
])) | ||
@pytest.mark.parametrize('return_indices', ([ | ||
False, | ||
True, | ||
])) | ||
@pytest.mark.nightly | ||
def test_adaptive_max_pool2d(self, ie_device, precision, ir_version, input_tensor, output_size, return_indices): | ||
self.input_tensor = input_tensor | ||
self._test(*self.create_model(output_size, return_indices), ie_device, precision, ir_version) |