Skip to content

Commit

Permalink
Bug where array that is being computed is optimized away
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwhite committed Aug 18, 2024
1 parent 19edd81 commit 0996185
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cubed/tests/test_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ def test_fusion(spec, opt_fn):
np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]).astype(np.float32),
)

# if we compute c and d then both have to be materialized
num_created_arrays = 2 # c, d
task_counter = TaskCounter()
c_result, d_result = cubed.compute(c, d, optimize_function=opt_fn)
assert task_counter.value == num_created_arrays + 8

assert_array_equal(
c_result,
np.array([[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]]).astype(np.float32),
)
assert_array_equal(
d_result,
np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]).astype(np.float32),
)


@pytest.mark.parametrize(
"opt_fn", [None, simple_optimize_dag, multiple_inputs_optimize_dag]
Expand Down

0 comments on commit 0996185

Please sign in to comment.