Skip to content

Commit 1d29dcc

Browse files
committed
merge to upstream
2 parents 8449c99 + a49035c commit 1d29dcc

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

stan/math/opencl/matrix_cl.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,13 +518,14 @@ class matrix_cl : public matrix_cl_base {
518518
for (std::size_t i = 0; i < write_events_size; ++i) {
519519
read_write_events[i] = read_events_vec[i];
520520
}
521-
for (std::size_t i = write_events_size, j = 0; i < read_write_size; ++i, ++j) {
521+
for (std::size_t i = write_events_size, j = 0; i < read_write_size;
522+
++i, ++j) {
522523
read_write_events[i] = write_events_vec[j];
523524
}
524525
try {
525-
opencl_context.queue().enqueueFillBuffer(
526-
buffer_cl_, static_cast<T>(0), 0, sizeof(T) * this->size(),
527-
&read_write_events, &zero_event);
526+
opencl_context.queue().enqueueFillBuffer(buffer_cl_, static_cast<T>(0), 0,
527+
sizeof(T) * this->size(),
528+
&read_write_events, &zero_event);
528529
} catch (const cl::Error& e) {
529530
check_opencl_error("setZero", e);
530531
}

stan/math/rev/core/var.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,6 @@ class var_value<T, internal::require_matrix_var_value<T>> {
390390
reverse_pass_callback(
391391
[this_vi = this->vi_, other_vi = other.vi_]() mutable {
392392
other_vi->adj_ += this_vi->adj_;
393-
// Reset the adjoint for `this` to replicate SoA before assignment
394-
this_vi->adj_.setZero();
395393
});
396394
}
397395

test/unit/math/rev/core/var_test.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -960,8 +960,7 @@ TEST_F(AgradRev, assign_nan_matvar) {
960960
EXPECT_MATRIX_EQ(z_ans_adj, z.adj());
961961
}
962962

963-
964-
TEST_F(AgradRev, assign_nullptr_vari) {
963+
TEST_F(AgradRev, assign_nullptr_var) {
965964
using stan::math::var_value;
966965
using var_vector = var_value<Eigen::Matrix<double, -1, 1>>;
967966
using stan::math::var;
@@ -980,6 +979,5 @@ TEST_F(AgradRev, assign_nullptr_vari) {
980979
x_ans_adj(i) = -(i + 0.1);
981980
}
982981
EXPECT_MATRIX_EQ(x.adj(), x_ans_adj);
983-
Eigen::VectorXd y_ans_adj = Eigen::VectorXd::Zero(10);
984-
EXPECT_MATRIX_EQ(y_ans_adj, y.adj());
982+
EXPECT_MATRIX_EQ(x_ans_adj, y.adj());
985983
}

0 commit comments

Comments
 (0)