Skip to content

Commit

Permalink
Added tests for tiling
Browse files Browse the repository at this point in the history
  • Loading branch information
anton164 committed Dec 8, 2020
1 parent afe5ea4 commit c62118c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test_nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@
from .strategies import tensors, assert_close
import pytest

@pytest.mark.task4_3
def test_tile():
t = minitorch.tensor_fromlist(
[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]
).view(1, 1, 4, 4)
tiled, _, _ = minitorch.tile(t, (2, 2))
assert tiled[0, 0, 0, 0, 0] == 1
assert tiled[0, 0, 0, 0, 1] == 2
assert tiled[0, 0, 0, 0, 2] == 5
assert tiled[0, 0, 0, 0, 3] == 6

@pytest.mark.task4_3
def test_tile_2():
t = minitorch.tensor_fromlist(
[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]
).view(1, 1, 4, 4)
tiled, _, _ = minitorch.tile(t, (1, 2))
assert tiled[0, 0, 0, 0, 0] == 1
assert tiled[0, 0, 0, 0, 1] == 2
assert tiled[0, 0, 0, 1, 0] == 3
assert tiled[0, 0, 0, 1, 1] == 4

@pytest.mark.task4_3
@given(tensors(shape=(1, 1, 4, 4)))
Expand Down

0 comments on commit c62118c

Please sign in to comment.