OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
class neg_model(torch.nn.Module):
def forward(self, x):
return x * (-x.shape[-1])
class TestNeg(PytorchLayerTest):
def _prepare_input(self):
return (self.random.randn(2, 4, 224, 224),)
@pytest.mark.nightly
@pytest.mark.precommit
@pytest.mark.precommit_torch_export
def test_neg(self, ie_device, precision, ir_version):
# Note: This test uses Python's built-in neg on shape dimension, not torch.neg on tensor
self._test(neg_model(), "aten::neg",
ie_device, precision, ir_version,
dynamic_shapes_for_export={
"x": {3: torch.export.Dim("width")}
},
fx_kind="<built-in function neg>")