示例#1
0
def test_relu():
    shape = (2000, 2500)
    x = np.random.uniform(-1, 1, shape).astype(dtype)
    y = np.zeros(shape).astype(dtype)
    arr_x = tvm.nd.array(x, ctx=ctx)
    arr_y = tvm.nd.array(y, ctx=ctx)
    relu = tvm_op.make_relu(shape, tgt, tgt_host, "relu")
    relu(arr_x, arr_y)
    y = arr_y.asnumpy()
    np.testing.assert_allclose(np.maximum(x, 0).astype(dtype), y)
def test_relu():
    shape = (2000, 2500)
    x = np.random.uniform(-1, 1, shape).astype(dtype)
    y = np.zeros(shape).astype(dtype)
    arr_x = tvm.nd.array(x, ctx=ctx)
    arr_y = tvm.nd.array(y, ctx=ctx)
    relu = tvm_op.make_relu(shape, tgt, tgt_host, "relu")
    relu(arr_x, arr_y)
    y = arr_y.asnumpy()
    np.testing.assert_allclose(np.maximum(x, 0).astype(dtype), y)