Files
openvino/tests/layer_tests/pytorch_tests/test_copy.py
T
Maxim Vafin 48dec1000e [PT FE] Support inplace operations on aliases of tensors (#17856)
* Support operations on aliases of tensors

* Add tests

* Fix issue with convnd

* Fix code style

* Fix issue with tensor index of mutated tensor

* Fix if types alignment

* Fix issues in keypoint detectron2

* Fix issue with masks in detectron2

* Fix acuracy issue in mobilevitv2 models

* Remove unused includes

* Return upsample case in lictconstruct replacer

* Fix types, apply review feedback

* Apply feedback

* Revert change of not using shared_from_this for getitem

* Fix issue in prim::device transformation

* Fix layer tests

* Apply review feedback

* Fix issue with not existing alias to tensor
2023-06-13 13:30:48 +02:00

34 lines
973 B
Python

# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
from pytorch_layer_test_class import PytorchLayerTest
class TestCopy(PytorchLayerTest):
def _prepare_input(self):
import numpy as np
return (np.random.randn(1, 3, 224, 224).astype(np.float32),)
def create_model(self, value):
import torch
class aten_copy(torch.nn.Module):
def __init__(self, value):
super(aten_copy, self).__init__()
self.value = torch.tensor(value)
def forward(self, x):
return x.copy_(self.value)
ref_net = None
return aten_copy(value), ref_net, "aten::copy_"
@pytest.mark.nightly
@pytest.mark.precommit
@pytest.mark.parametrize("value", [1, [2.5], range(224)])
def test_copy_(self, value, ie_device, precision, ir_version):
self._test(*self.create_model(value), ie_device, precision, ir_version)