forked from M-Labs/nac3
standalone: add test_ndarray_broadcast_to
This commit is contained in:
parent
117110dd91
commit
be6d704020
@ -220,6 +220,29 @@ def test_ndarray_subscript_assignment():
|
||||
zs[2:5] = np_array([1000.0, 2000.0, 3000.0])
|
||||
output_ndarray_float_2(xs)
|
||||
|
||||
def test_ndarray_broadcast_to():
|
||||
xs = np_array([1.0, 2.0])
|
||||
output_ndarray_float_1(xs)
|
||||
output_int32(np_shape(xs)[0])
|
||||
|
||||
ys = np_broadcast_to(xs, (1, 3, 2))
|
||||
output_ndarray_float_3(ys)
|
||||
output_int32(np_shape(ys)[0])
|
||||
output_int32(np_shape(ys)[1])
|
||||
output_int32(np_shape(ys)[2])
|
||||
|
||||
zs = np_broadcast_to(ys, (4, 3, 2))
|
||||
output_ndarray_float_3(zs)
|
||||
output_int32(np_shape(zs)[0])
|
||||
output_int32(np_shape(zs)[1])
|
||||
output_int32(np_shape(zs)[2])
|
||||
|
||||
# Broadcasting shares memory.
|
||||
zs[0, 0, 0] = 99
|
||||
output_ndarray_float_1(xs)
|
||||
output_ndarray_float_3(ys)
|
||||
output_ndarray_float_3(zs)
|
||||
|
||||
def test_ndarray_add():
|
||||
x = np_identity(2)
|
||||
y = x + np_ones([2, 2])
|
||||
|
Loading…
Reference in New Issue
Block a user