I've found some time lately to work again on binary vectorization. In particular, I'm trying to understand an error that I get while testing the mix scalar, int vector case, but I need some help. The toy function that I'm using is a constrained
pow function so I get the error when I'm essentially testing the case of
The code flow, which is similar to the unary vectorization, is the following:
test/unit/math/mix/mat/vectorize/expect_mix_binary_std_vector_value.hpp, the mix scalar, int vector test case is handled in the function
2. There, the mix scalar and int vectors are built.
F::apply_base are used to generate the "test" variable and "expected" variable respectively. Call our expected variables exp_var and our test variables test_var.
test/unit/math/mix/mat/vectorize/expect_binary_val_deriv_eq.hpp is called to unspool the mix variables and get the rev variables, which are then tested in
When the test fails in the case of
pow(0, -4), exp_var.d_'s reverse mode gradient is -inf whereas test_var.d_'s reverse mode gradient is nan. However, if
F::apply_base is called again or exp_var.d_'s gradient is taken inside of functions in
test/unit/math/mix/mat/vectorize/expect_mix_binary_std_vector_value.hpp, exp_var.d_'s reverse mode gradient is nan and so the tests should pass.
To understand this error, I've also checked that exp_var.d_'s gradient remains invariant in
test/unit/math/mix/mat/vectorize/expect_binary_val_deriv_eq.hpp even after setting all adjoints to zero or taking test_var.d_'s reverse gradient. Further,
F::apply_base's return type is correct and all the rev and fwd mode binary vectorization tests pass. I also checked the existing scalar mix
pow test to see if this error might come up there, but the test only tests cases in which the arguments are all positive.
So, I'm wondering what else I can check to debug this error. All the code can be found in the branch
feature/issue-202-vectorize-all-binary. The branch is up to date with develop.
(Also, this topic is created under the category of General because I couldn't put it under the category of Developers.)