Skip to content

Commit f90727d

Browse files
authored
Merge pull request #2630 from stan-dev/cxx_flag_for_rev_only_tests
Add the CXX flag for only running rev tests with the test_ad
2 parents 3595599 + 90969fc commit f90727d

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ jobs:
9393
- name: Add TBB to PATH
9494
shell: powershell
9595
run: echo "D:/a/math/math/lib/tbb" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
96+
- name: Disable running fwd/mix tests
97+
shell: powershell
98+
run: echo "CXXFLAGS+= -DSTAN_MATH_TESTS_REV_ONLY" | Out-File -Append -FilePath make/local -Encoding utf8
9699
- name: Run fwd unit tests and all the mix tests except those in mix/fun
97100
shell: powershell
98101
run: |
@@ -139,6 +142,9 @@ jobs:
139142
- name: Add TBB to PATH
140143
shell: powershell
141144
run: echo "D:/a/math/math/lib/tbb" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
145+
- name: Disable running fwd/mix tests
146+
shell: powershell
147+
run: echo "CXXFLAGS+= -DSTAN_MATH_TESTS_REV_ONLY" | Out-File -Append -FilePath make/local -Encoding utf8
142148
- name: Run mix/fun unit tests
143149
shell: powershell
144150
run: |

test/unit/math/test_ad.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ void test_gradient(const ad_tolerances& tols, const F& f,
138138
grad_ad, tols.gradient_grad_);
139139
}
140140

141+
#ifndef STAN_MATH_TESTS_REV_ONLY
141142
/**
142143
* Tests that the specified function applied to the specified argument
143144
* yields the values and gradients consistent with finite differences
@@ -309,6 +310,7 @@ void test_grad_hessian(const ad_tolerances& tols, const F& f,
309310
expect_near_rel("grad_hessian() grad Hessian", grad_H_fd[i], grad_H_ad[i],
310311
tols.grad_hessian_grad_hessian_);
311312
}
313+
#endif
312314

313315
/**
314316
* For the specified functor and argument, test that automatic
@@ -332,10 +334,12 @@ void expect_ad_derivatives(const ad_tolerances& tols, const G& g,
332334
const Eigen::VectorXd& x) {
333335
double gx = g(x);
334336
test_gradient(tols, g, x, gx);
337+
#ifndef STAN_MATH_TESTS_REV_ONLY
335338
test_gradient_fvar(tols, g, x, gx);
336339
test_hessian(tols, g, x, gx);
337340
test_hessian_fvar(tols, g, x, gx);
338341
test_grad_hessian(tols, g, x, gx);
342+
#endif
339343
}
340344

341345
/**
@@ -379,10 +383,12 @@ void expect_all_throw(const F& f, const Eigen::VectorXd& x) {
379383
using stan::math::var;
380384
expect_throw<double>(f, x, "double");
381385
expect_throw<var>(f, x, "var");
386+
#ifndef STAN_MATH_TESTS_REV_ONLY
382387
expect_throw<fvar<double>>(f, x, "fvar<double>");
383388
expect_throw<fvar<fvar<double>>>(f, x, "fvar<fvar<double>>");
384389
expect_throw<fvar<var>>(f, x, "fvar<var>");
385390
expect_throw<fvar<fvar<var>>>(f, x, "fvar<fvar<var>>");
391+
#endif
386392
}
387393

388394
/**

0 commit comments

Comments
 (0)