File: msan_generator.cpp

package info (click to toggle)
halide 14.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 49,124 kB
  • sloc: cpp: 238,722; makefile: 4,303; python: 4,047; java: 1,575; sh: 1,384; pascal: 211; xml: 165; javascript: 43; ansic: 34
file content (42 lines) | stat: -rw-r--r-- 1,249 bytes parent folder | download
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
#include "Halide.h"

namespace {

class MSAN : public Halide::Generator<MSAN> {
public:
    Input<Buffer<uint8_t, 3>> input{"input"};
    Output<Buffer<uint8_t, 3>> output{"output"};

    void generate() {
        // Currently the test just exercises Target::MSAN
        input_plus_1(x, y, c) = input(x, y, c) + 1;

        // This just makes an exact copy
        msan_extern_stage.define_extern("msan_extern_stage", {input_plus_1}, UInt(8), 3, NameMangling::C);

        RDom r(0, 4);
        output(x, y, c) = sum(msan_extern_stage(r, y, c));

        // Add two update phases to be sure annotation happens post-update
        output(r, y, c) += cast<uint8_t>(1);
        output(x, r, c) += cast<uint8_t>(2);
    }

    void schedule() {
        input_plus_1.compute_root();
        msan_extern_stage.compute_root();
        input.dim(0).set_stride(Expr()).set_extent(4).dim(1).set_extent(4).dim(2).set_extent(3);
        output.parallel(y).vectorize(x, 4);
        output.dim(0).set_stride(Expr()).set_extent(4).dim(1).set_extent(4).dim(2).set_extent(3);
    }

private:
    // Currently the test just exercises Target::MSAN
    Var x, y, c;

    Func input_plus_1, msan_extern_stage;
};

}  // namespace

HALIDE_REGISTER_GENERATOR(MSAN, msan)