-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.c
More file actions
150 lines (134 loc) · 4.75 KB
/
debug.c
File metadata and controls
150 lines (134 loc) · 4.75 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
#include "debug.h"
#include <stdio.h>
void dump_vertex(struct BNVertex* vertex) {
printf("vertex 0x%08x:", vertex);
switch (vertex->type) {
case BNV_CONST:
printf(" CONST, sample = %f", vertex->sample);
break;
case BNV_DRAW:
printf(" DRAW, sample = %f", vertex->sample);
dump_vertexDraw((struct BNVertexDraw*) vertex);
break;
case BNV_COMPU:
printf(" COMPUTE, sample = %f", vertex->sample);
dump_vertexCompute((struct BNVertexCompute*) vertex);
break;
default:
printf(" UNKNOWN");
}
printf("\n");
}
void dump_vertexDraw(struct BNVertexDraw* vertexDraw) {
switch (vertexDraw->type) {
case FLIP:
printf(", FLIP");
dump_vertexDrawBern((struct BNVertexDrawBern*) vertexDraw);
break;
case LOG_FLIP:
printf(", LOG_FLIP");
dump_vertexDrawBern((struct BNVertexDrawBern*) vertexDraw);
break;
case GAUSSIAN:
printf(", GAUSSIAN");
dump_vertexDrawNorm((struct BNVertexDrawNorm*) vertexDraw);
break;
case GAMMA:
printf(", GAMMA");
dump_vertexDrawGamma((struct BNVertexDrawGamma*) vertexDraw);
break;
default:
printf(", UNKNOWN");
}
}
void dump_vertexDrawBern(struct BNVertexDrawBern* vertexBern) {
printf(", p_node = 0x%08x, p = %f", vertexBern->p, vertexBern->p->sample);
}
void dump_vertexDrawNorm(struct BNVertexDrawNorm* vertexNorm) {
printf(", mu_node = 0x%08x, mu = %f, var_node = 0x%08x, var = %f",
vertexNorm->mean, vertexNorm->mean->sample,
vertexNorm->variance, vertexNorm->variance->sample);
}
void dump_vertexDrawGamma(struct BNVertexDrawGamma* vertexGamma) {
printf(", a_node = 0x%08x, a = %f, b_node = 0x%08x, b = %f",
vertexGamma->a, vertexGamma->a->sample,
vertexGamma->b, vertexGamma->b->sample);
}
void dump_vertexCompute(struct BNVertexCompute* vertexCompute) {
switch (vertexCompute->type) {
case BNVC_IF:
printf(", IF");
dump_vertexComputeIf((struct BNVertexComputeIf*) vertexCompute);
break;
case BNVC_BINOP:
printf(", BINOP");
dump_vertexComputeBinop((struct BNVertexComputeBinop*) vertexCompute);
break;
case BNVC_UNARY:
printf(", UNARY");
dump_vertexComputeUnary((struct BNVertexComputeUnary*) vertexCompute);
break;
case BNVC_FUNC:
printf(", FUNC");
dump_vertexComputeFunc((struct BNVertexComputeFunc*) vertexCompute);
break;
default:
printf(", UNKNOWN");
}
}
void dump_vertexComputeFunc(struct BNVertexComputeFunc* vertexComputeFunc) {
switch (vertexComputeFunc->func) {
case FUNC_LOG:
printf(", LOG, arg_node = 0x%08x, arg = %f", vertexComputeFunc->args[0], vertexComputeFunc->args[0]->sample);
break;
case FUNC_EXP:
printf(", EXP, arg_node = 0x%08x, arg = %f", vertexComputeFunc->args[0], vertexComputeFunc->args[0]->sample);
break;
default:
printf(", UNKNOWN");
}
}
void dump_vertexComputeUnary(struct BNVertexComputeUnary* vertexComputeUnary) {
switch (vertexComputeUnary->op) {
case UNARY_NEG:
printf(", NEG, operand_node = 0x%08x, operand = %f", vertexComputeUnary->primary, vertexComputeUnary->primary->sample);
break;
case UNARY_POS:
printf(", POS, operand_node = 0x%08x, opearnd = %f", vertexComputeUnary->primary, vertexComputeUnary->primary->sample);
break;
default:
printf(", UNKNOWN");
}
}
void dump_vertexComputeBinop(struct BNVertexComputeBinop* vertexComputeBinop) {
switch (vertexComputeBinop->binop) {
case BINOP_PLUS:
printf(", PLUS, left_node = 0x%08x, left = %f, right_node = 0x%08x, right = %f",
vertexComputeBinop->left, vertexComputeBinop->left->sample,
vertexComputeBinop->right, vertexComputeBinop->right->sample);
break;
case BINOP_SUB:
printf(", SUB, left_node = 0x%08x, left = %f, right_node = 0x%08x, right = %f",
vertexComputeBinop->left, vertexComputeBinop->left->sample,
vertexComputeBinop->right, vertexComputeBinop->right->sample);
break;
case BINOP_MULTI:
printf(", MULTI, left_node = 0x%08x, left = %f, right_node = 0x%08x, right = %f",
vertexComputeBinop->left, vertexComputeBinop->left->sample,
vertexComputeBinop->right, vertexComputeBinop->right->sample);
break;
case BINOP_DIV:
printf(", DIV, left_node = 0x%08x, left = %f, right_node = 0x%08x, right = %f",
vertexComputeBinop->left, vertexComputeBinop->left->sample,
vertexComputeBinop->right, vertexComputeBinop->right->sample);
break;
default:
printf(", UNKNOWN");
}
}
void dump_vertexComputeIf(struct BNVertexComputeIf* vertexComputeIf) {
printf(", IF, condition_node = 0x%08x, condition = %f, consequence_node = 0x%08x, consequence = %f, alternative_node = 0x%08x, alternative = %f",
vertexComputeIf->condition, vertexComputeIf->condition->sample,
vertexComputeIf->consequent, vertexComputeIf->consequent->sample,
vertexComputeIf->alternative, vertexComputeIf->alternative->sample);
}