Halide 19.0.0
Halide compiler and libraries
Loading...
Searching...
No Matches
ASLog.h
Go to the documentation of this file.
1#ifndef ASLOG_H
2#define ASLOG_H
3
4// This class is used by train_cost_model, which doesn't link to
5// libHalide, so (despite the namespace) we are better off not
6// including Halide.h, lest we reference something we won't have available
7
8#include <cassert>
9#include <cstdlib>
10#include <iostream>
11#include <utility>
12
13namespace Halide {
14namespace Internal {
15
16class aslog {
17 const bool logging;
18
19public:
20 explicit aslog(int verbosity)
21 : logging(verbosity <= aslog_level()) {
22 }
23
24 template<typename T>
25 aslog &operator<<(T &&x) {
26 if (logging) {
27 std::cerr << std::forward<T>(x);
28 }
29 return *this;
30 }
31
32 std::ostream &get_ostream() {
33 // It is an error to call this for an aslog() instance that cannot log.
34 assert(logging);
35 return std::cerr;
36 }
37
38 static int aslog_level();
39};
40
41} // namespace Internal
42} // namespace Halide
43
44#endif
aslog & operator<<(T &&x)
Definition ASLog.h:25
std::ostream & get_ostream()
Definition ASLog.h:32
aslog(int verbosity)
Definition ASLog.h:20
static int aslog_level()
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.