pytorch

Форк
0
25 строк · 797.0 Байт
1

2

3

4

5
import numpy as np
6
from hypothesis import given, settings
7
import hypothesis.strategies as st
8
from caffe2.python import core
9
import caffe2.python.hypothesis_test_util as hu
10

11

12
class TestAssert(hu.HypothesisTestCase):
13
    @given(
14
        dtype=st.sampled_from(['bool_', 'int32', 'int64']),
15
        shape=st.lists(elements=st.integers(1, 10), min_size=1, max_size=4),
16
        **hu.gcs)
17
    @settings(deadline=10000)
18
    def test_assert(self, dtype, shape, gc, dc):
19
        test_tensor = np.random.rand(*shape).astype(np.dtype(dtype))
20

21
        op = core.CreateOperator('Assert', ['X'], [])
22

23
        def assert_ref(X):
24
            return []
25

26
        try:
27
            self.assertReferenceChecks(gc, op, [test_tensor], assert_ref)
28
        except Exception:
29
            assert(not np.all(test_tensor))
30

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.