-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
Copy pathtest_is_nonzero.py
32 lines (22 loc) · 967 Bytes
/
test_is_nonzero.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Copyright (C) 2018-2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
import torch
from pytorch_layer_test_class import PytorchLayerTest
@pytest.mark.parametrize('input_tensor', (np.array([0.]), np.array([1.5]), np.array([False]), np.array([3])))
class TestIsNonZero(PytorchLayerTest):
def _prepare_input(self):
input_tensor = self.input_tensor
return (input_tensor.astype(np.int64),)
def create_model(self):
class aten_is_nonzero(torch.nn.Module):
def forward(self, input_tensor):
return torch.is_nonzero(input_tensor)
ref_net = None
return aten_is_nonzero(), ref_net, "aten::is_nonzero"
@pytest.mark.nightly
@pytest.mark.precommit
def test_is_nonzero(self, ie_device, precision, ir_version, input_tensor):
self.input_tensor = input_tensor
self._test(*self.create_model(), ie_device, precision, ir_version)