File: uninitialized_param_2.cpp

package info (click to toggle)
halide 19.0.0-6
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 55,096 kB
  • sloc: cpp: 286,920; ansic: 22,751; python: 5,821; makefile: 4,374; sh: 2,445; java: 1,549; javascript: 282; pascal: 212; xml: 127; asm: 9
file content (46 lines) | stat: -rw-r--r-- 1,179 bytes parent folder | download | duplicates (3)
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
#include "Halide.h"
#include "halide_test_dirs.h"
#include <stdio.h>

using namespace Halide;
using namespace Halide::ConciseCasts;

#include "Halide.h"

namespace {

Var x;

class PleaseFail : public Halide::Generator<PleaseFail> {
public:
    Input<Buffer<uint8_t, 1>> input{"input"};
    Input<float> scalar_input{"scalar_input"};
    Output<Buffer<uint8_t, 1>> output{"output"};

    void generate() {
        Func lut_fn("lut_fn");
        lut_fn(x) = u8_sat(x * scalar_input / 255.f);

        // This should always fail, because it depends on a scalar input
        // that *cannot* have a valid value at this point.
        auto lut = lut_fn.realize({256});

        output(x) = input(x) + lut[0](x);
    }
};

}  // namespace

HALIDE_REGISTER_GENERATOR(PleaseFail, PleaseFail)

int main(int argc, char **argv) {
    Halide::Internal::ExecuteGeneratorArgs args;
    args.output_dir = Internal::get_test_tmp_dir();
    args.output_types = std::set<OutputFileType>{OutputFileType::object};
    args.targets = std::vector<Target>{get_target_from_environment()};
    args.generator_name = "PleaseFail";
    execute_generator(args);

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