File: stmt_to_html.cpp

package info (click to toggle)
halide 21.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 55,752 kB
  • sloc: cpp: 289,334; ansic: 22,751; python: 7,486; makefile: 4,299; sh: 2,508; java: 1,549; javascript: 282; pascal: 207; xml: 127; asm: 9
file content (49 lines) | stat: -rw-r--r-- 1,708 bytes parent folder | download | duplicates (4)
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
#include "Halide.h"
#include "halide_test_dirs.h"

#include <cstdio>

using namespace Halide;

int main() {
    Var x, y;

    // The gradient function and schedule from tutorial lesson 5.
    Func gradient_fast("gradient_fast");
    gradient_fast(x, y) = x + y;

    Var x_outer, y_outer, x_inner, y_inner, tile_index;
    gradient_fast
        .tile(x, y, x_outer, y_outer, x_inner, y_inner, 256, 256)
        .fuse(x_outer, y_outer, tile_index)
        .parallel(tile_index);

    Var x_inner_outer, y_inner_outer, x_vectors, y_pairs;
    gradient_fast
        .tile(x_inner, y_inner, x_inner_outer, y_inner_outer, x_vectors, y_pairs, 4, 2)
        .vectorize(x_vectors)
        .unroll(y_pairs);

    std::string result_file_1 = Internal::get_test_tmp_dir() + "stmt_to_html_dump_1.html";
    Internal::ensure_no_file_exists(result_file_1);
    gradient_fast.compile_to_lowered_stmt(result_file_1, {}, Halide::HTML);
    Internal::assert_file_exists(result_file_1);

    // Also check using an image.
    std::string result_file_2 = Internal::get_test_tmp_dir() + "stmt_to_html_dump_2.html";
    Internal::ensure_no_file_exists(result_file_2);
    Buffer<int> im(800, 600);
    gradient_fast.compile_to_lowered_stmt(result_file_2, {im}, Halide::HTML);
    Internal::assert_file_exists(result_file_2);

    // Check a multi-output pipeline.
    std::string result_file_3 = Internal::get_test_tmp_dir() + "stmt_to_html_dump_3.html";
    Internal::ensure_no_file_exists(result_file_3);
    Func tuple_func;
    tuple_func(x, y) = Tuple(x, y);
    tuple_func.compile_to_lowered_stmt(result_file_3, {}, Halide::HTML);
    Internal::assert_file_exists(result_file_3);

    printf("Success!\n");
    return 0;
}