2024-03-27 17:06:58 +08:00
|
|
|
@extern
|
|
|
|
def output_bool(x: bool):
|
|
|
|
...
|
|
|
|
|
2024-02-19 17:10:44 +08:00
|
|
|
@extern
|
|
|
|
def output_int32(x: int32):
|
|
|
|
...
|
|
|
|
|
|
|
|
@extern
|
|
|
|
def output_float64(x: float):
|
|
|
|
...
|
|
|
|
|
2024-03-27 17:06:58 +08:00
|
|
|
def output_ndarray_bool_2(n: ndarray[bool, Literal[2]]):
|
|
|
|
for r in range(len(n)):
|
|
|
|
for c in range(len(n[r])):
|
|
|
|
output_bool(n[r][c])
|
|
|
|
|
2024-03-13 11:16:23 +08:00
|
|
|
def output_ndarray_int32_1(n: ndarray[int32, Literal[1]]):
|
|
|
|
for i in range(len(n)):
|
|
|
|
output_int32(n[i])
|
|
|
|
|
2024-03-27 17:06:58 +08:00
|
|
|
def output_ndarray_int32_2(n: ndarray[int32, Literal[2]]):
|
|
|
|
for r in range(len(n)):
|
|
|
|
for c in range(len(n[r])):
|
|
|
|
output_int32(n[r][c])
|
|
|
|
|
2024-03-13 11:16:23 +08:00
|
|
|
def output_ndarray_float_1(n: ndarray[float, Literal[1]]):
|
|
|
|
for i in range(len(n)):
|
|
|
|
output_float64(n[i])
|
|
|
|
|
|
|
|
def output_ndarray_float_2(n: ndarray[float, Literal[2]]):
|
|
|
|
for r in range(len(n)):
|
|
|
|
for c in range(len(n[r])):
|
|
|
|
output_float64(n[r][c])
|
|
|
|
|
2023-11-17 17:30:27 +08:00
|
|
|
def consume_ndarray_1(n: ndarray[float, Literal[1]]):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def test_ndarray_ctor():
|
2024-02-06 12:29:21 +08:00
|
|
|
n: ndarray[float, Literal[1]] = np_ndarray([1])
|
2023-11-17 17:30:27 +08:00
|
|
|
consume_ndarray_1(n)
|
|
|
|
|
|
|
|
def test_ndarray_empty():
|
2024-02-06 12:29:21 +08:00
|
|
|
n: ndarray[float, 1] = np_empty([1])
|
2023-11-17 17:30:27 +08:00
|
|
|
consume_ndarray_1(n)
|
|
|
|
|
2023-11-27 13:25:53 +08:00
|
|
|
def test_ndarray_zeros():
|
2024-02-06 12:29:21 +08:00
|
|
|
n: ndarray[float, 1] = np_zeros([1])
|
2024-03-13 11:16:23 +08:00
|
|
|
output_ndarray_float_1(n)
|
2023-11-27 13:25:53 +08:00
|
|
|
|
|
|
|
def test_ndarray_ones():
|
2024-02-06 12:29:21 +08:00
|
|
|
n: ndarray[float, 1] = np_ones([1])
|
2024-03-13 11:16:23 +08:00
|
|
|
output_ndarray_float_1(n)
|
2023-11-27 13:25:53 +08:00
|
|
|
|
|
|
|
def test_ndarray_full():
|
2024-02-06 12:29:21 +08:00
|
|
|
n_float: ndarray[float, 1] = np_full([1], 2.0)
|
2024-03-13 11:16:23 +08:00
|
|
|
output_ndarray_float_1(n_float)
|
2024-02-06 12:29:21 +08:00
|
|
|
n_i32: ndarray[int32, 1] = np_full([1], 2)
|
2024-03-13 11:16:23 +08:00
|
|
|
output_ndarray_int32_1(n_i32)
|
2023-11-27 13:25:53 +08:00
|
|
|
|
|
|
|
def test_ndarray_eye():
|
2024-02-06 12:29:21 +08:00
|
|
|
n: ndarray[float, 2] = np_eye(2)
|
2024-03-13 11:16:23 +08:00
|
|
|
output_ndarray_float_2(n)
|
2023-11-27 13:25:53 +08:00
|
|
|
|
|
|
|
def test_ndarray_identity():
|
2024-02-06 12:29:21 +08:00
|
|
|
n: ndarray[float, 2] = np_identity(2)
|
2024-03-13 11:16:23 +08:00
|
|
|
output_ndarray_float_2(n)
|
2023-11-27 13:25:53 +08:00
|
|
|
|
2024-03-06 16:53:41 +08:00
|
|
|
def test_ndarray_fill():
|
|
|
|
n: ndarray[float, 2] = np_empty([2, 2])
|
|
|
|
n.fill(1.0)
|
2024-03-13 11:16:23 +08:00
|
|
|
output_ndarray_float_2(n)
|
2024-03-06 16:53:41 +08:00
|
|
|
|
2024-03-07 13:08:45 +08:00
|
|
|
def test_ndarray_copy():
|
|
|
|
x: ndarray[float, 2] = np_identity(2)
|
|
|
|
y = x.copy()
|
|
|
|
x.fill(0.0)
|
|
|
|
|
2024-03-13 11:16:23 +08:00
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_add():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x + np_ones([2, 2])
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_add_broadcast():
|
|
|
|
x = np_identity(2)
|
|
|
|
# y: ndarray[float, 2] = x + np_ones([2])
|
|
|
|
y = x + np_ones([2])
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_add_broadcast_lhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
# y: ndarray[float, 2] = 1.0 + x
|
|
|
|
y = 1.0 + x
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_add_broadcast_rhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
# y: ndarray[float, 2] = x + 1.0
|
|
|
|
y = x + 1.0
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_iadd():
|
|
|
|
x = np_identity(2)
|
|
|
|
x += np_ones([2, 2])
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
|
|
|
|
def test_ndarray_iadd_broadcast():
|
|
|
|
x = np_identity(2)
|
|
|
|
x += np_ones([2])
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
|
|
|
|
def test_ndarray_iadd_broadcast_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
x += 1.0
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
|
|
|
|
def test_ndarray_sub():
|
|
|
|
x = np_ones([2, 2])
|
|
|
|
y = x - np_identity(2)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_sub_broadcast():
|
|
|
|
x = np_identity(2)
|
|
|
|
# y: ndarray[float, 2] = x - np_ones([2])
|
|
|
|
y = x - np_ones([2])
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_sub_broadcast_lhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
# y: ndarray[float, 2] = 1.0 - x
|
|
|
|
y = 1.0 - x
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_sub_broadcast_rhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
# y: ndarray[float, 2] = x - 1
|
|
|
|
y = x - 1.0
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_isub():
|
|
|
|
x = np_ones([2, 2])
|
|
|
|
x -= np_identity(2)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
|
|
|
|
def test_ndarray_isub_broadcast():
|
|
|
|
x = np_identity(2)
|
|
|
|
x -= np_ones([2])
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
|
|
|
|
def test_ndarray_isub_broadcast_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
x -= 1.0
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
|
|
|
|
def test_ndarray_mul():
|
|
|
|
x = np_ones([2, 2])
|
|
|
|
y = x * np_identity(2)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_mul_broadcast():
|
|
|
|
x = np_identity(2)
|
|
|
|
# y: ndarray[float, 2] = x * np_ones([2])
|
|
|
|
y = x * np_ones([2])
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_mul_broadcast_lhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
# y: ndarray[float, 2] = 2.0 * x
|
|
|
|
y = 2.0 * x
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_mul_broadcast_rhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
# y: ndarray[float, 2] = x * 2.0
|
|
|
|
y = x * 2.0
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_imul():
|
|
|
|
x = np_ones([2, 2])
|
|
|
|
x *= np_identity(2)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
|
|
|
|
def test_ndarray_imul_broadcast():
|
|
|
|
x = np_identity(2)
|
|
|
|
x *= np_ones([2])
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
|
|
|
|
def test_ndarray_imul_broadcast_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
x *= 2.0
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
|
|
|
|
def test_ndarray_truediv():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x / np_ones([2, 2])
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_truediv_broadcast():
|
|
|
|
x = np_identity(2)
|
|
|
|
# y: ndarray[float, 2] = x / np_ones([2])
|
|
|
|
y = x / np_ones([2])
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_truediv_broadcast_lhs_scalar():
|
|
|
|
x = np_ones([2, 2])
|
|
|
|
# y: ndarray[float, 2] = 2.0 / x
|
|
|
|
y = 2.0 / x
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_truediv_broadcast_rhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
# y: ndarray[float, 2] = x / 2.0
|
|
|
|
y = x / 2.0
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_itruediv():
|
|
|
|
x = np_identity(2)
|
|
|
|
x /= np_ones([2, 2])
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
|
|
|
|
def test_ndarray_itruediv_broadcast():
|
|
|
|
x = np_identity(2)
|
|
|
|
x /= np_ones([2])
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
|
|
|
|
def test_ndarray_itruediv_broadcast_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
x /= 2.0
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
|
|
|
|
def test_ndarray_floordiv():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x // np_ones([2, 2])
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_floordiv_broadcast():
|
|
|
|
x = np_identity(2)
|
|
|
|
# y: ndarray[float, 2] = x // np_ones([2])
|
|
|
|
y = x // np_ones([2])
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_floordiv_broadcast_lhs_scalar():
|
|
|
|
x = np_ones([2, 2])
|
|
|
|
# y: ndarray[float, 2] = 2.0 // x
|
|
|
|
y = 2.0 // x
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_floordiv_broadcast_rhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
# y: ndarray[float, 2] = x // 2.0
|
|
|
|
y = x // 2.0
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_ifloordiv():
|
|
|
|
x = np_identity(2)
|
|
|
|
x //= np_ones([2, 2])
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
|
|
|
|
def test_ndarray_ifloordiv_broadcast():
|
|
|
|
x = np_identity(2)
|
|
|
|
x //= np_ones([2])
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
|
|
|
|
def test_ndarray_ifloordiv_broadcast_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
x //= 2.0
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
|
|
|
|
def test_ndarray_mod():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x % np_full([2, 2], 2.0)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_mod_broadcast():
|
|
|
|
x = np_identity(2)
|
|
|
|
# y: ndarray[float, 2] = x % np_ones([2])
|
|
|
|
y = x % np_full([2], 2.0)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_mod_broadcast_lhs_scalar():
|
|
|
|
x = np_ones([2, 2])
|
|
|
|
# y: ndarray[float, 2] = 2.0 % x
|
|
|
|
y = 2.0 % x
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_mod_broadcast_rhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
# y: ndarray[float, 2] = x % 2.0
|
|
|
|
y = x % 2.0
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_imod():
|
|
|
|
x = np_identity(2)
|
|
|
|
x %= np_full([2, 2], 2.0)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
|
|
|
|
def test_ndarray_imod_broadcast():
|
|
|
|
x = np_identity(2)
|
|
|
|
x %= np_full([2], 2.0)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
|
|
|
|
def test_ndarray_imod_broadcast_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
x %= 2.0
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
|
|
|
|
def test_ndarray_pow():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x ** np_full([2, 2], 2.0)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_pow_broadcast():
|
|
|
|
x = np_identity(2)
|
|
|
|
# y: ndarray[float, 2] = x ** np_full([2], 2.0)
|
|
|
|
y = x ** np_full([2], 2.0)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_pow_broadcast_lhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
# y: ndarray[float, 2] = 2.0 ** x
|
|
|
|
y = 2.0 ** x
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_pow_broadcast_rhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
# y: ndarray[float, 2] = x % 2.0
|
|
|
|
y = x ** 2.0
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_float_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_ipow():
|
|
|
|
x = np_identity(2)
|
|
|
|
x **= np_full([2, 2], 2.0)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
|
|
|
|
def test_ndarray_ipow_broadcast():
|
|
|
|
x = np_identity(2)
|
|
|
|
x **= np_full([2], 2.0)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
|
|
|
|
def test_ndarray_ipow_broadcast_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
x **= 2.0
|
2024-03-07 13:08:45 +08:00
|
|
|
|
2024-03-13 11:16:23 +08:00
|
|
|
output_ndarray_float_2(x)
|
2024-03-07 13:08:45 +08:00
|
|
|
|
2024-03-27 17:06:58 +08:00
|
|
|
def test_ndarray_pos():
|
|
|
|
x_int32 = np_full([2, 2], -2)
|
|
|
|
y_int32 = +x_int32
|
|
|
|
|
|
|
|
output_ndarray_int32_2(x_int32)
|
|
|
|
output_ndarray_int32_2(y_int32)
|
|
|
|
|
|
|
|
x_float = np_full([2, 2], -2.0)
|
|
|
|
y_float = +x_float
|
|
|
|
|
|
|
|
output_ndarray_float_2(x_float)
|
|
|
|
output_ndarray_float_2(y_float)
|
|
|
|
|
|
|
|
def test_ndarray_neg():
|
|
|
|
x_int32 = np_full([2, 2], -2)
|
|
|
|
y_int32 = -x_int32
|
|
|
|
|
|
|
|
output_ndarray_int32_2(x_int32)
|
|
|
|
output_ndarray_int32_2(y_int32)
|
|
|
|
|
|
|
|
x_float = np_full([2, 2], 2.0)
|
|
|
|
y_float = -x_float
|
|
|
|
|
|
|
|
output_ndarray_float_2(x_float)
|
|
|
|
output_ndarray_float_2(y_float)
|
|
|
|
|
|
|
|
def test_ndarray_inv():
|
|
|
|
x_int32 = np_full([2, 2], -2)
|
|
|
|
y_int32 = ~x_int32
|
|
|
|
|
|
|
|
output_ndarray_int32_2(x_int32)
|
|
|
|
output_ndarray_int32_2(y_int32)
|
|
|
|
|
2024-04-12 15:35:36 +08:00
|
|
|
x_bool = np_full([2, 2], True)
|
|
|
|
y_bool = ~x_bool
|
|
|
|
|
|
|
|
output_ndarray_bool_2(x_bool)
|
|
|
|
output_ndarray_bool_2(y_bool)
|
|
|
|
|
2024-03-27 12:57:11 +08:00
|
|
|
def test_ndarray_eq():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x == np_full([2, 2], 0.0)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_eq_broadcast():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x == np_full([2], 0.0)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_eq_broadcast_lhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = 0.0 == x
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_eq_broadcast_rhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x == 0.0
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_ne():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x != np_full([2, 2], 0.0)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_ne_broadcast():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x != np_full([2], 0.0)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_ne_broadcast_lhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = 0.0 != x
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_ne_broadcast_rhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x != 0.0
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_lt():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x < np_full([2, 2], 1.0)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_lt_broadcast():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x < np_full([2], 1.0)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_lt_broadcast_lhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = 1.0 < x
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_lt_broadcast_rhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x < 1.0
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_le():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x <= np_full([2, 2], 0.5)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_le_broadcast():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x <= np_full([2], 0.5)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_le_broadcast_lhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = 0.5 <= x
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_le_broadcast_rhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x <= 0.5
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_gt():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x > np_full([2, 2], 0.0)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_gt_broadcast():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x > np_full([2], 0.0)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_gt_broadcast_lhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = 0.0 > x
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_gt_broadcast_rhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x > 0.0
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_ge():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x >= np_full([2, 2], 0.5)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_ge_broadcast():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x >= np_full([2], 0.5)
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_ge_broadcast_lhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = 0.5 >= x
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
|
|
|
def test_ndarray_ge_broadcast_rhs_scalar():
|
|
|
|
x = np_identity(2)
|
|
|
|
y = x >= 0.5
|
|
|
|
|
|
|
|
output_ndarray_float_2(x)
|
|
|
|
output_ndarray_bool_2(y)
|
|
|
|
|
2023-11-17 17:30:27 +08:00
|
|
|
def run() -> int32:
|
|
|
|
test_ndarray_ctor()
|
|
|
|
test_ndarray_empty()
|
2023-11-27 13:25:53 +08:00
|
|
|
test_ndarray_zeros()
|
|
|
|
test_ndarray_ones()
|
|
|
|
test_ndarray_full()
|
|
|
|
test_ndarray_eye()
|
|
|
|
test_ndarray_identity()
|
2024-03-06 16:53:41 +08:00
|
|
|
test_ndarray_fill()
|
2024-03-07 13:08:45 +08:00
|
|
|
test_ndarray_copy()
|
2024-03-13 11:16:23 +08:00
|
|
|
test_ndarray_add()
|
|
|
|
test_ndarray_add_broadcast()
|
|
|
|
test_ndarray_add_broadcast_lhs_scalar()
|
|
|
|
test_ndarray_add_broadcast_rhs_scalar()
|
|
|
|
test_ndarray_iadd()
|
|
|
|
test_ndarray_iadd_broadcast()
|
|
|
|
test_ndarray_iadd_broadcast_scalar()
|
|
|
|
test_ndarray_sub()
|
|
|
|
test_ndarray_sub_broadcast()
|
|
|
|
test_ndarray_sub_broadcast_lhs_scalar()
|
|
|
|
test_ndarray_sub_broadcast_rhs_scalar()
|
|
|
|
test_ndarray_isub()
|
|
|
|
test_ndarray_isub_broadcast()
|
|
|
|
test_ndarray_isub_broadcast_scalar()
|
|
|
|
test_ndarray_mul()
|
|
|
|
test_ndarray_mul_broadcast()
|
|
|
|
test_ndarray_mul_broadcast_lhs_scalar()
|
|
|
|
test_ndarray_mul_broadcast_rhs_scalar()
|
|
|
|
test_ndarray_imul()
|
|
|
|
test_ndarray_imul_broadcast()
|
|
|
|
test_ndarray_imul_broadcast_scalar()
|
|
|
|
test_ndarray_truediv()
|
|
|
|
test_ndarray_truediv_broadcast()
|
|
|
|
test_ndarray_truediv_broadcast_lhs_scalar()
|
|
|
|
test_ndarray_truediv_broadcast_rhs_scalar()
|
|
|
|
test_ndarray_itruediv()
|
|
|
|
test_ndarray_itruediv_broadcast()
|
|
|
|
test_ndarray_itruediv_broadcast_scalar()
|
|
|
|
test_ndarray_floordiv()
|
|
|
|
test_ndarray_floordiv_broadcast()
|
|
|
|
test_ndarray_floordiv_broadcast_lhs_scalar()
|
|
|
|
test_ndarray_floordiv_broadcast_rhs_scalar()
|
|
|
|
test_ndarray_ifloordiv()
|
|
|
|
test_ndarray_ifloordiv_broadcast()
|
|
|
|
test_ndarray_ifloordiv_broadcast_scalar()
|
|
|
|
test_ndarray_mod()
|
|
|
|
test_ndarray_mod_broadcast()
|
|
|
|
test_ndarray_mod_broadcast_lhs_scalar()
|
|
|
|
test_ndarray_mod_broadcast_rhs_scalar()
|
|
|
|
test_ndarray_imod()
|
|
|
|
test_ndarray_imod_broadcast()
|
|
|
|
test_ndarray_imod_broadcast_scalar()
|
|
|
|
test_ndarray_pow()
|
|
|
|
test_ndarray_pow_broadcast()
|
|
|
|
test_ndarray_pow_broadcast_lhs_scalar()
|
|
|
|
test_ndarray_pow_broadcast_rhs_scalar()
|
|
|
|
test_ndarray_ipow()
|
|
|
|
test_ndarray_ipow_broadcast()
|
|
|
|
test_ndarray_ipow_broadcast_scalar()
|
2024-03-27 17:06:58 +08:00
|
|
|
test_ndarray_pos()
|
|
|
|
test_ndarray_neg()
|
|
|
|
test_ndarray_inv()
|
2024-03-27 12:57:11 +08:00
|
|
|
test_ndarray_eq()
|
|
|
|
test_ndarray_eq_broadcast()
|
|
|
|
test_ndarray_eq_broadcast_lhs_scalar()
|
|
|
|
test_ndarray_eq_broadcast_rhs_scalar()
|
|
|
|
test_ndarray_ne()
|
|
|
|
test_ndarray_ne_broadcast()
|
|
|
|
test_ndarray_ne_broadcast_lhs_scalar()
|
|
|
|
test_ndarray_ne_broadcast_rhs_scalar()
|
|
|
|
test_ndarray_lt()
|
|
|
|
test_ndarray_lt_broadcast()
|
|
|
|
test_ndarray_lt_broadcast_lhs_scalar()
|
|
|
|
test_ndarray_lt_broadcast_rhs_scalar()
|
|
|
|
test_ndarray_lt()
|
|
|
|
test_ndarray_le_broadcast()
|
|
|
|
test_ndarray_le_broadcast_lhs_scalar()
|
|
|
|
test_ndarray_le_broadcast_rhs_scalar()
|
|
|
|
test_ndarray_gt()
|
|
|
|
test_ndarray_gt_broadcast()
|
|
|
|
test_ndarray_gt_broadcast_lhs_scalar()
|
|
|
|
test_ndarray_gt_broadcast_rhs_scalar()
|
|
|
|
test_ndarray_gt()
|
|
|
|
test_ndarray_ge_broadcast()
|
|
|
|
test_ndarray_ge_broadcast_lhs_scalar()
|
|
|
|
test_ndarray_ge_broadcast_rhs_scalar()
|
2023-11-17 17:30:27 +08:00
|
|
|
|
|
|
|
return 0
|