def test_array_set(): ctx = ndarray.gpu(0) shape = (500, 200) # oneslike arr_x = ndarray.empty(shape, ctx=ctx) gpu_op.array_set(arr_x, 1.) x = arr_x.asnumpy() np.testing.assert_allclose(np.ones(shape), x) # zeroslike gpu_op.array_set(arr_x, 0.) x = arr_x.asnumpy() np.testing.assert_allclose(np.zeros(shape), x)
def test_array_set(): ctx = ndarray.gpu(0) shape = (500, 200) # oneslike arr_x = ndarray.empty(shape, ctx=ctx) gpu_op.array_set(arr_x, 1.) x = arr_x.asnumpy() ''' for i in range(500): for j in range(200): if x[i][j] != 1: print(str(i) + ' ' + str(j) + ' ' + str(x[i][j])) break ''' np.testing.assert_allclose(np.ones(shape), x) # zeroslike gpu_op.array_set(arr_x, 0.) x = arr_x.asnumpy() np.testing.assert_allclose(np.zeros(shape), x)