forked from halide/Halide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebugArguments.cpp
More file actions
44 lines (40 loc) · 1.42 KB
/
DebugArguments.cpp
File metadata and controls
44 lines (40 loc) · 1.42 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
#include "DebugArguments.h"
#include "Function.h"
#include "IR.h"
#include "IROperator.h"
#include "Module.h"
namespace Halide {
namespace Internal {
using std::vector;
void debug_arguments(LoweredFunc *func, const Target &t) {
internal_assert(func);
vector<Stmt> stmts;
stmts.push_back(Evaluate::make(print("Entering Pipeline " + func->name)));
stmts.push_back(Evaluate::make(print("Target: " + t.to_string())));
for (const LoweredArgument &arg : func->args) {
std::ostringstream name;
Expr scalar_var = Variable::make(arg.type, arg.name);
Expr buffer_var = Variable::make(type_of<halide_buffer_t *>(), arg.name + ".buffer");
Expr value;
switch (arg.kind) {
case Argument::InputScalar:
name << " Input " << arg.type << " " << arg.name << ":";
value = scalar_var;
break;
case Argument::InputBuffer:
name << " Input Buffer " << arg.name << ":";
value = buffer_var;
break;
case Argument::OutputBuffer:
name << " Output Buffer " << arg.name << ":";
value = buffer_var;
break;
}
stmts.push_back(Evaluate::make(print(name.str(), value)));
}
stmts.push_back(func->body);
stmts.push_back(Evaluate::make(print("Exiting Pipeline " + func->name)));
func->body = Block::make(stmts);
}
} // namespace Internal
} // namespace Halide