From f45eea9bca81827e2a1f459bc6f851fc4210521d Mon Sep 17 00:00:00 2001 From: Manolis Papadakis Date: Thu, 6 Jan 2022 18:25:09 -0800 Subject: [PATCH 1/2] Adjust error tolerance for float16, to avoid spurious test failure --- tests/matrix_mul.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/matrix_mul.py b/tests/matrix_mul.py index 671ec6e4d..31194d40b 100644 --- a/tests/matrix_mul.py +++ b/tests/matrix_mul.py @@ -19,6 +19,7 @@ def test(ty): + rtol = 2e-03 if ty == np.float16 else 1e-05 np.random.seed(42) A = num.random.randn(6, 3, 7).astype(ty) @@ -29,7 +30,7 @@ def test(ty): Bn = B.__array__() Cn = An[1].dot(Bn[2]) - assert np.allclose(C, Cn) + assert np.allclose(C, Cn, rtol=rtol) An = np.random.randn(3, 7).astype(ty) Bn = np.random.randn(11, 7).astype(ty) @@ -39,7 +40,7 @@ def test(ty): BT = num.array(Bn) C = A.dot(BT.transpose()) - assert np.allclose(C, Cn) + assert np.allclose(C, Cn, rtol=rtol) An = np.random.randn(7, 3).astype(ty) Bn = np.random.randn(7, 11).astype(ty) @@ -49,7 +50,7 @@ def test(ty): B = num.array(Bn) C = AT.transpose().dot(B) - assert np.allclose(C, Cn) + assert np.allclose(C, Cn, rtol=rtol) An = np.random.randn(7, 3).astype(ty) Bn = np.random.randn(11, 7).astype(ty) @@ -59,7 +60,7 @@ def test(ty): BT = num.array(Bn) C = AT.transpose().dot(BT.transpose()) - assert np.allclose(C, Cn) + assert np.allclose(C, Cn, rtol=rtol) A3np = np.empty((2, 7, 3), dtype=ty) B3np = np.empty((2, 11, 7), dtype=ty) @@ -73,7 +74,7 @@ def test(ty): B3[0] = B3np[0] C = A3[0].T.dot(B3[0].T) - assert np.allclose(C, Cn) + assert np.allclose(C, Cn, rtol=rtol) A = num.random.randn(1, 10).astype(ty) B = num.random.randn(10, 1).astype(ty) @@ -83,7 +84,7 @@ def test(ty): Bn = B.__array__() Cn = An.dot(Bn) - assert np.allclose(C, Cn) + assert np.allclose(C, Cn, rtol=rtol) if __name__ == "__main__": From 97b6c7c0368fd7e635369e54c5d0d3b098a2a6e8 Mon Sep 17 00:00:00 2001 From: Manolis Papadakis Date: Thu, 6 Jan 2022 19:24:00 -0800 Subject: [PATCH 2/2] Add some references between python & C++ enums --- cunumeric/config.py | 5 +++-- src/cunumeric/binary/binary_op_util.h | 1 + src/cunumeric/cunumeric_c.h | 6 +++--- src/cunumeric/random/rand_util.h | 1 + src/cunumeric/unary/unary_op_util.h | 1 + src/cunumeric/unary/unary_red_util.h | 1 + 6 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cunumeric/config.py b/cunumeric/config.py index 7b5bf73dd..cd2258684 100644 --- a/cunumeric/config.py +++ b/cunumeric/config.py @@ -111,7 +111,7 @@ class CuNumericOpCode(IntEnum): WRITE = _cunumeric.CUNUMERIC_WRITE -# Match these to BinaryOpCode in binary_op_util.h +# Match these to BinaryOpCode in binary_op_util.h @unique class BinaryOpCode(IntEnum): ADD = 1 @@ -168,7 +168,7 @@ class UnaryOpCode(IntEnum): GETARG = 28 -# Match these to UnaryRedCode in unary_red_util.h +# Match these to UnaryRedCode in unary_red_util.h @unique class UnaryRedCode(IntEnum): ALL = 1 @@ -183,6 +183,7 @@ class UnaryRedCode(IntEnum): COUNT_NONZERO = 10 +# Match these to RandGenCode in rand_util.h @unique class RandGenCode(IntEnum): UNIFORM = 1 diff --git a/src/cunumeric/binary/binary_op_util.h b/src/cunumeric/binary/binary_op_util.h index e73ad061d..d367733a9 100644 --- a/src/cunumeric/binary/binary_op_util.h +++ b/src/cunumeric/binary/binary_op_util.h @@ -20,6 +20,7 @@ namespace cunumeric { +// Match these to BinaryOpCode in config.py enum class BinaryOpCode : int { ADD = 1, DIVIDE, diff --git a/src/cunumeric/cunumeric_c.h b/src/cunumeric/cunumeric_c.h index fe8129b12..e9dea60ea 100644 --- a/src/cunumeric/cunumeric_c.h +++ b/src/cunumeric/cunumeric_c.h @@ -19,7 +19,7 @@ #include "legate_preamble.h" -// Match these to CuNumericOpCode in cunumeric/config.py +// Match these to CuNumericOpCode in config.py // Also, sort these alphabetically except the first one for easy lookup later enum CuNumericOpCode { _CUNUMERIC_OP_CODE_BASE = 0, @@ -54,13 +54,13 @@ enum CuNumericOpCode { CUNUMERIC_WRITE, }; -// Match these to CuNumericRedopCode in cunumeric/config.py +// Match these to CuNumericRedopCode in config.py enum CuNumericRedopID { CUNUMERIC_ARGMAX_REDOP = 1, CUNUMERIC_ARGMIN_REDOP = 2, }; -// Match these to CuNumericTunable in cunumeric/config.py +// Match these to CuNumericTunable in config.py enum CuNumericTunable { CUNUMERIC_TUNABLE_NUM_GPUS = 1, CUNUMERIC_TUNABLE_NUM_PROCS = 2, diff --git a/src/cunumeric/random/rand_util.h b/src/cunumeric/random/rand_util.h index ee9718d1b..4ab097822 100644 --- a/src/cunumeric/random/rand_util.h +++ b/src/cunumeric/random/rand_util.h @@ -24,6 +24,7 @@ namespace cunumeric { +// Match these to RandGenCode in config.py enum class RandGenCode : int32_t { UNIFORM = 1, NORMAL = 2, diff --git a/src/cunumeric/unary/unary_op_util.h b/src/cunumeric/unary/unary_op_util.h index 307b75ca0..a07cf417c 100644 --- a/src/cunumeric/unary/unary_op_util.h +++ b/src/cunumeric/unary/unary_op_util.h @@ -24,6 +24,7 @@ namespace cunumeric { +// Match these to UnaryOpCode in config.py enum class UnaryOpCode : int { ABSOLUTE = 1, ARCCOS, diff --git a/src/cunumeric/unary/unary_red_util.h b/src/cunumeric/unary/unary_red_util.h index 40338d8e6..b5d8e5aae 100644 --- a/src/cunumeric/unary/unary_red_util.h +++ b/src/cunumeric/unary/unary_red_util.h @@ -21,6 +21,7 @@ namespace cunumeric { +// Match these to UnaryRedCode in config.py enum class UnaryRedCode : int { ALL = 1, ANY = 2,