Skip to content

Commit 044d2bc

Browse files
committed
1 parent 1dbf607 commit 044d2bc

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

stan/math/mix/functor/laplace_marginal_density.hpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ inline void set_zero_adjoint(Output&& output) {
312312
} else if constexpr (is_stan_scalar_v<output_i_t>) {
313313
output_i.adj() = 0;
314314
} else {
315-
throw std::domain_error(
315+
static_assert(
316+
sizeof(std::decay_t<output_i_t>*) == 0,
316317
"INTERNAL ERROR:(laplace_marginal_lpdf) set_zero_adjoints was "
317318
"not able to deduce the actions needed for the given type.");
318319
}
@@ -356,7 +357,8 @@ inline void collect_adjoints(Output& output, Input&& input) {
356357
input_i.adj() = 0;
357358
}
358359
} else {
359-
throw std::domain_error(
360+
static_assert(
361+
sizeof(std::decay_t<output_i_t>*) == 0,
360362
"INTERNAL ERROR:(laplace_marginal_lpdf) set_zero_adjoints was "
361363
"not able to deduce the actions needed for the given type.");
362364
}
@@ -809,7 +811,8 @@ inline void collect_adjoints(Output&& output, Input&& input) {
809811
} else if constexpr (is_stan_scalar_v<output_i_t>) {
810812
output_i += input_i;
811813
} else {
812-
throw std::domain_error(
814+
static_assert(
815+
sizeof(std::decay_t<output_i_t>*) == 0,
813816
"INTERNAL ERROR:(laplace_marginal_lpdf) set_zero_adjoints was "
814817
"not able to deduce the actions needed for the given type.");
815818
}
@@ -858,7 +861,8 @@ inline void copy_compute_s2(Output&& output, Input&& input) {
858861
input_i.adj() = 0;
859862
}
860863
} else {
861-
throw std::domain_error(
864+
static_assert(
865+
sizeof(std::decay_t<output_i_t>*) == 0,
862866
"INTERNAL ERROR:(laplace_marginal_lpdf) set_zero_adjoints was "
863867
"not able to deduce the actions needed for the given type.");
864868
}
@@ -916,12 +920,12 @@ inline constexpr auto make_zeroed_arena(Input&& input) {
916920
template <typename Output, typename Input>
917921
inline void collect_adjoints(Output&& output, const vari* ret, Input&& input) {
918922
if constexpr (is_tuple_v<Output>) {
919-
throw std::domain_error(
920-
"INTERNAL ERROR:(laplace_marginal_lpdf)"
921-
"Accumulate Adjoints called on a tuple, but tuples cannot be "
922-
"on the reverse mode stack!"
923-
"This is an internal error, please report it to the stan "
924-
"github as an issue.");
923+
static_assert(sizeof(std::decay_t<Output>*) == 0,
924+
"INTERNAL ERROR:(laplace_marginal_lpdf)"
925+
"Accumulate Adjoints called on a tuple, but tuples cannot be "
926+
"on the reverse mode stack!"
927+
"This is an internal error, please report it to the stan "
928+
"github as an issue.");
925929
} else if constexpr (is_std_vector_v<Output>) {
926930
if constexpr (!is_var_v<value_type_t<Output>>) {
927931
const auto output_size = output.size();

0 commit comments

Comments
 (0)