예제 #1
0
def test_with_random(a, b):
    rstate = random_initialize(123)
    rstate, v0 = random_uint32(rstate, (2, 3))
    _, v1 = random_uint32(rstate, (2, 3))
    v0 = array_cast(v0, xtype.f64)
    v1 = array_cast(v1, xtype.f64)
    return a * np.sum(v0).item() + b * np.sum(v1).item()
예제 #2
0
def test_array_cast():
    assert isinstance(array_cast(np.array([1.5, 1.7]), type_to_abstract(i64)),
                      np.ndarray)
    assert (array_cast(np.array([1.5, 1.7]),
                       type_to_abstract(i64))).dtype == np.dtype(np.int64)
    assert isinstance(array_cast(np.array([1.5, 1.7]), type_to_abstract(f16)),
                      np.ndarray)
    assert (array_cast(np.array([1.5, 1.]),
                       type_to_abstract(f16))).dtype == np.dtype(np.float16)