-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathall_tests.c
More file actions
323 lines (310 loc) · 15.4 KB
/
all_tests.c
File metadata and controls
323 lines (310 loc) · 15.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
#include <stdio.h>
#include "minunit.h"
/* Include all test headers */
#ifndef PROFILE_ONLY
#include "forward_pass/affine/test_add.h"
#include "forward_pass/affine/test_broadcast.h"
#include "forward_pass/affine/test_diag_mat.h"
#include "forward_pass/affine/test_hstack.h"
#include "forward_pass/affine/test_linear_op.h"
#include "forward_pass/affine/test_neg.h"
#include "forward_pass/affine/test_promote.h"
#include "forward_pass/affine/test_sum.h"
#include "forward_pass/affine/test_upper_tri.h"
#include "forward_pass/affine/test_variable_constant.h"
#include "forward_pass/composite/test_composite.h"
#include "forward_pass/elementwise/test_exp.h"
#include "forward_pass/elementwise/test_log.h"
#include "forward_pass/elementwise/test_normal_cdf.h"
#include "forward_pass/test_left_matmul_dense.h"
#include "forward_pass/test_matmul.h"
#include "forward_pass/test_prod_axis_one.h"
#include "forward_pass/test_prod_axis_zero.h"
#include "jacobian_tests/test_broadcast.h"
#include "jacobian_tests/test_composite.h"
#include "jacobian_tests/test_const_scalar_mult.h"
#include "jacobian_tests/test_const_vector_mult.h"
#include "jacobian_tests/test_diag_mat.h"
#include "jacobian_tests/test_elementwise_mult.h"
#include "jacobian_tests/test_hstack.h"
#include "jacobian_tests/test_index.h"
#include "jacobian_tests/test_left_matmul.h"
#include "jacobian_tests/test_log.h"
#include "jacobian_tests/test_matmul.h"
#include "jacobian_tests/test_neg.h"
#include "jacobian_tests/test_prod.h"
#include "jacobian_tests/test_prod_axis_one.h"
#include "jacobian_tests/test_prod_axis_zero.h"
#include "jacobian_tests/test_promote.h"
#include "jacobian_tests/test_quad_form.h"
#include "jacobian_tests/test_quad_over_lin.h"
#include "jacobian_tests/test_rel_entr.h"
#include "jacobian_tests/test_rel_entr_scalar_vector.h"
#include "jacobian_tests/test_rel_entr_vector_scalar.h"
#include "jacobian_tests/test_right_matmul.h"
#include "jacobian_tests/test_sum.h"
#include "jacobian_tests/test_trace.h"
#include "jacobian_tests/test_transpose.h"
#include "jacobian_tests/test_upper_tri.h"
#include "problem/test_problem.h"
#include "utils/test_cblas.h"
#include "utils/test_coo_matrix.h"
#include "utils/test_csc_matrix.h"
#include "utils/test_csr_csc_conversion.h"
#include "utils/test_csr_matrix.h"
#include "utils/test_linalg_sparse_matmuls.h"
#include "utils/test_matrix.h"
#include "wsum_hess/elementwise/test_entr.h"
#include "wsum_hess/elementwise/test_exp.h"
#include "wsum_hess/elementwise/test_hyperbolic.h"
#include "wsum_hess/elementwise/test_log.h"
#include "wsum_hess/elementwise/test_logistic.h"
#include "wsum_hess/elementwise/test_power.h"
#include "wsum_hess/elementwise/test_trig.h"
#include "wsum_hess/elementwise/test_xexp.h"
#include "wsum_hess/test_broadcast.h"
#include "wsum_hess/test_const_scalar_mult.h"
#include "wsum_hess/test_const_vector_mult.h"
#include "wsum_hess/test_diag_mat.h"
#include "wsum_hess/test_hstack.h"
#include "wsum_hess/test_index.h"
#include "wsum_hess/test_left_matmul.h"
#include "wsum_hess/test_matmul.h"
#include "wsum_hess/test_multiply.h"
#include "wsum_hess/test_prod.h"
#include "wsum_hess/test_prod_axis_one.h"
#include "wsum_hess/test_prod_axis_zero.h"
#include "wsum_hess/test_quad_form.h"
#include "wsum_hess/test_quad_over_lin.h"
#include "wsum_hess/test_rel_entr.h"
#include "wsum_hess/test_rel_entr_scalar_vector.h"
#include "wsum_hess/test_rel_entr_vector_scalar.h"
#include "wsum_hess/test_right_matmul.h"
#include "wsum_hess/test_sum.h"
#include "wsum_hess/test_trace.h"
#include "wsum_hess/test_transpose.h"
#include "wsum_hess/test_upper_tri.h"
#endif /* PROFILE_ONLY */
#ifdef PROFILE_ONLY
#include "profiling/profile_left_matmul.h"
#endif /* PROFILE_ONLY */
int main(void)
{
printf("=== Running All Tests ===\n\n");
int tests_run = 0;
#ifndef PROFILE_ONLY
printf("--- Forward Pass Tests ---\n");
mu_run_test(test_variable, tests_run);
mu_run_test(test_constant, tests_run);
mu_run_test(test_addition, tests_run);
mu_run_test(test_linear_op, tests_run);
mu_run_test(test_neg_forward, tests_run);
mu_run_test(test_promote_scalar_to_vector, tests_run);
mu_run_test(test_exp, tests_run);
mu_run_test(test_log, tests_run);
mu_run_test(test_normal_cdf, tests_run);
mu_run_test(test_composite, tests_run);
mu_run_test(test_sum_axis_neg1, tests_run);
mu_run_test(test_sum_axis_0, tests_run);
mu_run_test(test_sum_axis_1, tests_run);
mu_run_test(test_hstack_forward_vectors, tests_run);
mu_run_test(test_hstack_forward_matrix, tests_run);
mu_run_test(test_broadcast_row, tests_run);
mu_run_test(test_broadcast_col, tests_run);
mu_run_test(test_broadcast_matrix, tests_run);
mu_run_test(test_forward_prod_axis_zero, tests_run);
mu_run_test(test_forward_prod_axis_one, tests_run);
mu_run_test(test_matmul, tests_run);
mu_run_test(test_left_matmul_dense, tests_run);
mu_run_test(test_diag_mat_forward, tests_run);
mu_run_test(test_upper_tri_forward, tests_run);
printf("\n--- Jacobian Tests ---\n");
mu_run_test(test_neg_jacobian, tests_run);
mu_run_test(test_neg_chain, tests_run);
mu_run_test(test_jacobian_log, tests_run);
mu_run_test(test_jacobian_log_matrix, tests_run);
mu_run_test(test_jacobian_composite_log, tests_run);
mu_run_test(test_jacobian_composite_log_add, tests_run);
mu_run_test(test_jacobian_const_scalar_mult_log_vector, tests_run);
mu_run_test(test_jacobian_const_scalar_mult_log_matrix, tests_run);
mu_run_test(test_jacobian_const_vector_mult_log_vector, tests_run);
mu_run_test(test_jacobian_const_vector_mult_log_matrix, tests_run);
mu_run_test(test_jacobian_rel_entr_vector_args_1, tests_run);
mu_run_test(test_jacobian_rel_entr_vector_args_2, tests_run);
mu_run_test(test_jacobian_rel_entr_matrix_args, tests_run);
mu_run_test(test_jacobian_rel_entr_vector_scalar, tests_run);
mu_run_test(test_jacobian_rel_entr_scalar_vector, tests_run);
mu_run_test(test_jacobian_elementwise_mult_1, tests_run);
mu_run_test(test_jacobian_elementwise_mult_2, tests_run);
mu_run_test(test_jacobian_elementwise_mult_3, tests_run);
mu_run_test(test_jacobian_elementwise_mult_4, tests_run);
mu_run_test(test_quad_over_lin1, tests_run);
mu_run_test(test_quad_over_lin2, tests_run);
mu_run_test(test_quad_over_lin3, tests_run);
mu_run_test(test_quad_over_lin4, tests_run);
mu_run_test(test_quad_over_lin5, tests_run);
mu_run_test(test_quad_form, tests_run);
/* commented out - see test_quad_form.h */
// mu_run_test(test_quad_form2, tests_run);
mu_run_test(test_jacobian_prod_no_zero, tests_run);
mu_run_test(test_jacobian_prod_one_zero, tests_run);
mu_run_test(test_jacobian_prod_two_zeros, tests_run);
mu_run_test(test_jacobian_prod_axis_zero, tests_run);
mu_run_test(test_jacobian_prod_axis_one, tests_run);
mu_run_test(test_jacobian_prod_axis_one_one_zero, tests_run);
mu_run_test(test_jacobian_sum_log, tests_run);
mu_run_test(test_jacobian_sum_mult, tests_run);
mu_run_test(test_jacobian_sum_log_axis_0, tests_run);
mu_run_test(test_jacobian_sum_add_log_axis_0, tests_run);
mu_run_test(test_jacobian_sum_log_axis_1, tests_run);
mu_run_test(test_jacobian_hstack_vectors, tests_run);
mu_run_test(test_jacobian_hstack_matrix, tests_run);
mu_run_test(test_index_forward_simple, tests_run);
mu_run_test(test_index_forward_repeated, tests_run);
mu_run_test(test_index_jacobian_of_variable, tests_run);
mu_run_test(test_index_jacobian_of_log, tests_run);
mu_run_test(test_index_jacobian_repeated, tests_run);
mu_run_test(test_sum_of_index, tests_run);
mu_run_test(test_promote_scalar_jacobian, tests_run);
mu_run_test(test_promote_scalar_to_matrix_jacobian, tests_run);
mu_run_test(test_broadcast_row_jacobian, tests_run);
mu_run_test(test_broadcast_col_jacobian, tests_run);
mu_run_test(test_broadcast_scalar_to_matrix_jacobian, tests_run);
mu_run_test(test_double_broadcast, tests_run);
mu_run_test(test_wsum_hess_multiply_1, tests_run);
mu_run_test(test_wsum_hess_multiply_2, tests_run);
mu_run_test(test_jacobian_trace_variable, tests_run);
mu_run_test(test_jacobian_trace_composite, tests_run);
mu_run_test(test_jacobian_left_matmul_log, tests_run);
mu_run_test(test_jacobian_left_matmul_log_matrix, tests_run);
mu_run_test(test_jacobian_left_matmul_log_composite, tests_run);
mu_run_test(test_jacobian_right_matmul_log, tests_run);
mu_run_test(test_jacobian_right_matmul_log_vector, tests_run);
mu_run_test(test_jacobian_matmul, tests_run);
mu_run_test(test_jacobian_transpose, tests_run);
mu_run_test(test_diag_mat_jacobian_variable, tests_run);
mu_run_test(test_diag_mat_jacobian_of_log, tests_run);
mu_run_test(test_upper_tri_jacobian_variable, tests_run);
mu_run_test(test_upper_tri_jacobian_of_log, tests_run);
printf("\n--- Weighted Sum of Hessian Tests ---\n");
mu_run_test(test_wsum_hess_log, tests_run);
mu_run_test(test_wsum_hess_log_composite, tests_run);
mu_run_test(test_wsum_hess_exp, tests_run);
mu_run_test(test_wsum_hess_entr, tests_run);
mu_run_test(test_wsum_hess_logistic, tests_run);
mu_run_test(test_wsum_hess_power, tests_run);
mu_run_test(test_wsum_hess_xexp, tests_run);
mu_run_test(test_wsum_hess_sin, tests_run);
mu_run_test(test_wsum_hess_cos, tests_run);
mu_run_test(test_wsum_hess_tan, tests_run);
mu_run_test(test_wsum_hess_sinh, tests_run);
mu_run_test(test_wsum_hess_tanh, tests_run);
mu_run_test(test_wsum_hess_asinh, tests_run);
mu_run_test(test_wsum_hess_atanh, tests_run);
mu_run_test(test_wsum_hess_sum_log_linear, tests_run);
mu_run_test(test_wsum_hess_sum_log_axis0, tests_run);
mu_run_test(test_wsum_hess_sum_log_axis1, tests_run);
mu_run_test(test_wsum_hess_prod_no_zero, tests_run);
mu_run_test(test_wsum_hess_prod_one_zero, tests_run);
mu_run_test(test_wsum_hess_prod_two_zeros, tests_run);
mu_run_test(test_wsum_hess_prod_many_zeros, tests_run);
mu_run_test(test_wsum_hess_prod_axis_zero_no_zeros, tests_run);
mu_run_test(test_wsum_hess_prod_axis_zero_one_zero, tests_run);
mu_run_test(test_wsum_hess_prod_axis_zero_mixed_zeros, tests_run);
mu_run_test(test_wsum_hess_prod_axis_one_no_zeros, tests_run);
mu_run_test(test_wsum_hess_prod_axis_one_one_zero, tests_run);
mu_run_test(test_wsum_hess_prod_axis_one_mixed_zeros, tests_run);
mu_run_test(test_wsum_hess_prod_axis_one_2x2, tests_run);
mu_run_test(test_wsum_hess_rel_entr_1, tests_run);
mu_run_test(test_wsum_hess_rel_entr_2, tests_run);
mu_run_test(test_wsum_hess_rel_entr_matrix, tests_run);
mu_run_test(test_wsum_hess_rel_entr_vector_scalar, tests_run);
mu_run_test(test_wsum_hess_rel_entr_scalar_vector, tests_run);
mu_run_test(test_wsum_hess_hstack, tests_run);
mu_run_test(test_wsum_hess_hstack_matrix, tests_run);
mu_run_test(test_wsum_hess_index_log, tests_run);
mu_run_test(test_wsum_hess_index_repeated, tests_run);
mu_run_test(test_wsum_hess_sum_index_log, tests_run);
mu_run_test(test_wsum_hess_quad_over_lin_xy, tests_run);
mu_run_test(test_wsum_hess_quad_over_lin_yx, tests_run);
mu_run_test(test_wsum_hess_quad_form, tests_run);
mu_run_test(test_wsum_hess_const_scalar_mult_log_vector, tests_run);
mu_run_test(test_wsum_hess_const_scalar_mult_log_matrix, tests_run);
mu_run_test(test_wsum_hess_const_vector_mult_log_vector, tests_run);
mu_run_test(test_wsum_hess_const_vector_mult_log_matrix, tests_run);
mu_run_test(test_wsum_hess_multiply_linear_ops, tests_run);
mu_run_test(test_wsum_hess_multiply_sparse_random, tests_run);
mu_run_test(test_wsum_hess_multiply_1, tests_run);
mu_run_test(test_wsum_hess_multiply_2, tests_run);
mu_run_test(test_wsum_hess_left_matmul, tests_run);
mu_run_test(test_wsum_hess_left_matmul_matrix, tests_run);
mu_run_test(test_wsum_hess_left_matmul_composite, tests_run);
mu_run_test(test_wsum_hess_matmul, tests_run);
mu_run_test(test_wsum_hess_matmul_yx, tests_run);
mu_run_test(test_wsum_hess_right_matmul, tests_run);
mu_run_test(test_wsum_hess_right_matmul_vector, tests_run);
mu_run_test(test_wsum_hess_broadcast_row, tests_run);
mu_run_test(test_wsum_hess_broadcast_col, tests_run);
mu_run_test(test_wsum_hess_broadcast_scalar_to_matrix, tests_run);
mu_run_test(test_wsum_hess_trace_variable, tests_run);
mu_run_test(test_wsum_hess_trace_log_variable, tests_run);
mu_run_test(test_wsum_hess_trace_composite, tests_run);
mu_run_test(test_wsum_hess_transpose, tests_run);
mu_run_test(test_wsum_hess_diag_mat_log, tests_run);
mu_run_test(test_wsum_hess_upper_tri_log, tests_run);
printf("\n--- Utility Tests ---\n");
mu_run_test(test_cblas_ddot, tests_run);
mu_run_test(test_diag_csr_mult, tests_run);
mu_run_test(test_csr_sum, tests_run);
mu_run_test(test_csr_sum2, tests_run);
mu_run_test(test_transpose, tests_run);
mu_run_test(test_AT_alloc_and_fill, tests_run);
mu_run_test(test_kron_identity_csr, tests_run);
mu_run_test(test_csr_to_csc1, tests_run);
mu_run_test(test_csr_to_csc2, tests_run);
mu_run_test(test_csr_to_csc_split, tests_run);
mu_run_test(test_csc_to_csr_sparsity, tests_run);
mu_run_test(test_csc_to_csr_values, tests_run);
mu_run_test(test_csr_csc_csr_roundtrip, tests_run);
mu_run_test(test_block_left_multiply_single_block, tests_run);
mu_run_test(test_block_left_multiply_two_blocks, tests_run);
mu_run_test(test_block_left_multiply_zero_column, tests_run);
mu_run_test(test_csr_csc_matmul_alloc_basic, tests_run);
mu_run_test(test_csr_csc_matmul_alloc_sparse, tests_run);
mu_run_test(test_block_left_multiply_vec_single_block, tests_run);
mu_run_test(test_block_left_multiply_vec_two_blocks, tests_run);
mu_run_test(test_block_left_multiply_vec_sparse, tests_run);
mu_run_test(test_block_left_multiply_vec_three_blocks, tests_run);
mu_run_test(test_csr_vecmat_values_sparse, tests_run);
mu_run_test(test_sum_all_rows_csr, tests_run);
mu_run_test(test_sum_block_of_rows_csr, tests_run);
mu_run_test(test_sum_evenly_spaced_rows_csr, tests_run);
mu_run_test(test_ATA_alloc_simple, tests_run);
mu_run_test(test_ATA_alloc_diagonal_like, tests_run);
mu_run_test(test_ATA_alloc_random, tests_run);
mu_run_test(test_ATA_alloc_random2, tests_run);
mu_run_test(test_BTA_alloc_and_BTDA_fill, tests_run);
mu_run_test(test_csr_to_coo, tests_run);
mu_run_test(test_csr_to_coo_lower_triangular, tests_run);
mu_run_test(test_refresh_lower_triangular_coo, tests_run);
mu_run_test(test_dense_matrix_mult_vec, tests_run);
mu_run_test(test_dense_matrix_mult_vec_blocks, tests_run);
mu_run_test(test_sparse_vs_dense_mult_vec, tests_run);
mu_run_test(test_dense_matrix_trans, tests_run);
mu_run_test(test_sparse_vs_dense_mult_vec_blocks, tests_run);
printf("\n--- Problem Struct Tests ---\n");
mu_run_test(test_problem_new_free, tests_run);
mu_run_test(test_problem_objective_forward, tests_run);
mu_run_test(test_problem_gradient, tests_run);
mu_run_test(test_problem_jacobian, tests_run);
mu_run_test(test_problem_jacobian_multi, tests_run);
mu_run_test(test_problem_constraint_forward, tests_run);
mu_run_test(test_problem_hessian, tests_run);
#endif /* PROFILE_ONLY */
#ifdef PROFILE_ONLY
printf("\n--- Profiling Tests ---\n");
mu_run_test(profile_left_matmul, tests_run);
#endif /* PROFILE_ONLY */
printf("\n=== All %d tests passed ===\n", tests_run);
return 0;
}