Skip to content

Commit

Permalink
Merge pull request #3219 from stan-dev/fix/opencl-assign-test
Browse files Browse the repository at this point in the history
update opencl assign test to reassign zero sized vector after recover_memory()
  • Loading branch information
SteveBronder authored Oct 18, 2023
2 parents 0f202e8 + 9432d32 commit 88cffcf
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/test/unit/model/indexing/assign_cl_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ TEST(ModelIndexing, assign_opencl_vector_1d) {
set_adjoints1(m1_v_cl);

stan::math::grad();

EXPECT_MATRIX_EQ(m1_v1.adj(),
stan::math::from_matrix_cl(m1_v_cl.adj()));
EXPECT_MATRIX_EQ(m1_v1.val(),
Expand All @@ -112,7 +111,6 @@ TEST(ModelIndexing, assign_opencl_vector_1d) {
EXPECT_ANY_THROW(assign(m_empty_v_cl,
rvalue(m2_cl, "rvalue double cl", index_cl),
"double cl index err", index_cl));

stan::math::recover_memory();

// rev = rev
Expand All @@ -136,9 +134,7 @@ TEST(ModelIndexing, assign_opencl_vector_1d) {
set_adjoints2(m2_v1);
set_adjoints1(m1_v_cl);
set_adjoints2(m2_v_cl);

stan::math::grad();

EXPECT_MATRIX_EQ(m1_v1.adj(),
stan::math::from_matrix_cl(m1_v_cl.adj()));
EXPECT_MATRIX_EQ(m2_v1.adj(),
Expand All @@ -151,10 +147,10 @@ TEST(ModelIndexing, assign_opencl_vector_1d) {
stan::math::var_value<stan::math::matrix_cl<double>> m_v_err = m_err;
EXPECT_THROW(assign(m1_v_cl, m_v_err, "double err2", index_cl),
std::invalid_argument);
m_empty_v_cl = stan::math::matrix_cl<double>(0, 1);
EXPECT_ANY_THROW(assign(m_empty_v_cl,
rvalue(m2_v_cl, "rvalue double cl", index_cl),
"double cl index err", index_cl));

rvalue(m2_v_cl, "rvalue var cl", index_cl),
"var cl index err", index_cl));
stan::math::recover_memory();
},
indices);
Expand Down

0 comments on commit 88cffcf

Please sign in to comment.