|
|
|
@@ -163,3 +163,77 @@ def test_scatter_update_large_shape_float16(): |
|
|
|
[88., 89., 90., 91.], |
|
|
|
[92., 93., 94., 95.]]]]).astype(np.float16) |
|
|
|
np.testing.assert_array_almost_equal(output.asnumpy(), expected) |
|
|
|
|
|
|
|
@pytest.mark.level0 |
|
|
|
@pytest.mark.platform_x86_gpu_training |
|
|
|
@pytest.mark.env_onecard |
|
|
|
def test_scatter_update_disordered_int8(): |
|
|
|
inputx = Tensor(np.flip(np.arange(34, 46).reshape(3, 4).astype(np.int8))) |
|
|
|
indices = Tensor(np.array([1, 2]).astype(np.int32)) |
|
|
|
updates = Tensor(np.arange(63, 71).reshape((2, 4)).astype(np.int8)) |
|
|
|
output = scatter_update_net(inputx, indices, updates) |
|
|
|
expected = np.array([[45., 44., 43., 42.], |
|
|
|
[63., 64., 65., 66.], |
|
|
|
[67., 68., 69., 70.]]).astype(np.int8) |
|
|
|
np.testing.assert_array_almost_equal(output.asnumpy(), expected) |
|
|
|
|
|
|
|
@pytest.mark.level0 |
|
|
|
@pytest.mark.platform_x86_gpu_training |
|
|
|
@pytest.mark.env_onecard |
|
|
|
def test_scatter_update_large_shape_int8(): |
|
|
|
inputx = Tensor(np.arange(96).reshape((4, 2, 3, 4)).astype(np.int8)) |
|
|
|
indices = Tensor(np.array([1, 0]).astype(np.int32)) |
|
|
|
updates = Tensor(np.flip(np.arange(48).reshape((2, 2, 3, 4)).astype(np.int8))) |
|
|
|
output = scatter_update_net(inputx, indices, updates) |
|
|
|
expected = np.array([[[[23., 22., 21., 20.], |
|
|
|
[19., 18., 17., 16.], |
|
|
|
[15., 14., 13., 12.]], |
|
|
|
[[11., 10., 9., 8.], |
|
|
|
[7., 6., 5., 4.], |
|
|
|
[3., 2., 1., 0.]]], |
|
|
|
[[[47., 46., 45., 44.], |
|
|
|
[43., 42., 41., 40.], |
|
|
|
[39., 38., 37., 36.]], |
|
|
|
[[35., 34., 33., 32.], |
|
|
|
[31., 30., 29., 28.], |
|
|
|
[27., 26., 25., 24.]]], |
|
|
|
[[[48., 49., 50., 51.], |
|
|
|
[52., 53., 54., 55.], |
|
|
|
[56., 57., 58., 59.]], |
|
|
|
[[60., 61., 62., 63.], |
|
|
|
[64., 65., 66., 67.], |
|
|
|
[68., 69., 70., 71.]]], |
|
|
|
[[[72., 73., 74., 75.], |
|
|
|
[76., 77., 78., 79.], |
|
|
|
[80., 81., 82., 83.]], |
|
|
|
[[84., 85., 86., 87.], |
|
|
|
[88., 89., 90., 91.], |
|
|
|
[92., 93., 94., 95.]]]]).astype(np.int8) |
|
|
|
np.testing.assert_array_almost_equal(output.asnumpy(), expected) |
|
|
|
|
|
|
|
@pytest.mark.level0 |
|
|
|
@pytest.mark.platform_x86_gpu_training |
|
|
|
@pytest.mark.env_onecard |
|
|
|
def test_scatter_update_large_uint8(): |
|
|
|
inputx = Tensor(np.zeros((4, 3)).astype(np.uint8)) |
|
|
|
indices = Tensor(np.array([[2, 1], [0, 3]]).astype(np.int32)) |
|
|
|
updates = Tensor(np.arange(63, 75).reshape((2, 2, 3)).astype(np.uint8)) |
|
|
|
output = scatter_update_net(inputx, indices, updates) |
|
|
|
expected = np.array([[69., 70., 71.], |
|
|
|
[66., 67., 68.], |
|
|
|
[63., 64., 65.], |
|
|
|
[72., 73., 74.]]).astype(np.uint8) |
|
|
|
np.testing.assert_array_almost_equal(output.asnumpy(), expected) |
|
|
|
|
|
|
|
@pytest.mark.level0 |
|
|
|
@pytest.mark.platform_x86_gpu_training |
|
|
|
@pytest.mark.env_onecard |
|
|
|
def test_scatter_update_disordered_uint8(): |
|
|
|
inputx = Tensor(np.flip(np.arange(34, 46).reshape(3, 4).astype(np.uint8))) |
|
|
|
indices = Tensor(np.array([1, 2]).astype(np.int32)) |
|
|
|
updates = Tensor(np.arange(63, 71).reshape((2, 4)).astype(np.uint8)) |
|
|
|
output = scatter_update_net(inputx, indices, updates) |
|
|
|
expected = np.array([[45., 44., 43., 42.], |
|
|
|
[63., 64., 65., 66.], |
|
|
|
[67., 68., 69., 70.]]).astype(np.uint8) |
|
|
|
np.testing.assert_array_almost_equal(output.asnumpy(), expected) |