Skip to content

Commit

Permalink
Fixed direct-extern
Browse files Browse the repository at this point in the history
  • Loading branch information
Fixstars-iizuka committed Jan 4, 2024
1 parent 486a597 commit abdc95e
Showing 1 changed file with 18 additions and 27 deletions.
45 changes: 18 additions & 27 deletions test/direct-extern.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,41 @@ int main()
try {
int size = 32;

Param wp{"width", std::to_string(size)};
Param hp{"height", std::to_string(size)};
Param vp{"v", std::to_string(1)};

Builder b;
b.set_target(Halide::get_host_target().with_feature(Halide::Target::Profile)); // CPU
b.with_bb_module("ion-bb");
b.with_bb_module("ion-bb-test");

Node n;
Port ip{"input", Halide::type_of<int32_t>(), 2};
n = b.add("test_extern_inc_i32x2")(ip).set_param(wp, hp, vp);
n = b.add("base_schedule")(n["output"]).set_param(Param{"output_name", "b1"}, Param{"compute_level", "compute_inline"});
n = b.add("test_extern_inc_i32x2")(n["output"]).set_param(wp, hp, vp);
n = b.add("base_schedule")(n["output"]).set_param(Param{"output_name", "b2"}, Param{"compute_level", "compute_inline"});

PortMap pm;
Param wp("width", size);
Param hp("height", size);
Param vp("v", 1);

Halide::Buffer<int32_t> ibuf(std::vector<int32_t>{size, size});
for (int y=0; y<size; ++y) {
for (int x=0; x<size; ++x) {
ibuf(x, y) = 42;
}
}
pm.set(ip, ibuf);

Halide::Buffer<int32_t> obuf(std::vector<int32_t>{size, size});
for (int y=0; y<size; ++y) {
for (int x=0; x<size; ++x) {
ibuf(x, y) = 42;
obuf(x, y) = 0;
}
}
pm.set(n["output"], obuf);

b.run(pm);
Builder b;
b.set_target(Halide::get_host_target().with_feature(Halide::Target::Profile)); // CPU
b.with_bb_module("ion-bb");
b.with_bb_module("ion-bb-test");

Node n;
n = b.add("test_extern_inc_i32x2")(ibuf).set_param(wp, hp, vp);
n = b.add("base_schedule")(n["output"]).set_param(Param("output_name", "b1"), Param("compute_level", "compute_inline"));
n = b.add("test_extern_inc_i32x2")(n["output"]).set_param(wp, hp, vp);
n = b.add("base_schedule")(n["output"]).set_param(Param("output_name", "b2"), Param("compute_level", "compute_inline"));
n["output"].bind(obuf);

b.run();

for (int y=0; y<size; ++y) {
for (int x=0; x<size; ++x) {
if (obuf(x, y) != 44) {
std::cout << obuf(x, y) << std::endl;
throw std::runtime_error("Invalid value");
}
}
}

} catch (const Halide::Error& e) {
std::cerr << e.what() << std::endl;
return 1;
Expand Down

0 comments on commit abdc95e

Please sign in to comment.