Skip to content

Commit

Permalink
Fixed all testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
Fixstars-iizuka committed Jan 5, 2024
1 parent abdc95e commit c93c641
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 136 deletions.
5 changes: 0 additions & 5 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ if(UNIX AND NOT APPLE)
ion_jit(port-access SRCS port-access.cc)
add_dependencies(port-access ion-bb-test)
ion_register_test(port-access_test port-access)

# PortMap index access
ion_jit(portmap-access SRCS portmap-access.cc)
add_dependencies(portmap-access ion-bb-test)
ion_register_test(portmap-access_test portmap-access)
endif()

ion_jit(direct-extern SRCS direct-extern.cc)
Expand Down
36 changes: 18 additions & 18 deletions test/array_output.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,37 @@ int main() {
try {
constexpr size_t h = 12, w = 10, len = 5;

Port input{"input", Halide::type_of<int32_t>(), 2};
Builder b;
b.set_target(Halide::get_host_target());
Node n;
n = b.add("test_array_output")(input).set_param(Param{"len", std::to_string(len)});
n = b.add("test_array_copy")(n["array_output"]).set_param(Param{"len", std::to_string(len)});

Halide::Buffer<int32_t> in(w, h);
ion::Buffer<int32_t> in(w, h);
for (int y = 0; y < h; ++y) {
for (int x = 0; x < w; ++x) {
in(x, y) = y * w + x;
}
}

std::vector<Halide::Buffer<int32_t>> outs{
Halide::Buffer<int32_t>{w, h},
Halide::Buffer<int32_t>{w, h},
Halide::Buffer<int32_t>{w, h},
Halide::Buffer<int32_t>{w, h},
Halide::Buffer<int32_t>{w, h}
std::vector<ion::Buffer<int32_t>> outs{
ion::Buffer<int32_t>{w, h},
ion::Buffer<int32_t>{w, h},
ion::Buffer<int32_t>{w, h},
ion::Buffer<int32_t>{w, h},
ion::Buffer<int32_t>{w, h}
};

for (auto &b : outs) {
b.fill(0);
}

PortMap pm;
pm.set(input, in);
Builder b;
b.set_target(ion::get_host_target());

Node n;
n = b.add("test_array_output")(in).set_param(Param("len", len));
n = b.add("test_array_copy")(n["array_output"]).set_param(Param("len", len));

for (size_t i=0; i<len; ++i) {
pm.set(n["array_output"][i], outs[i]);
n["array_output"][i].bind(outs[i]);
}
b.run(pm);

b.run();

for (auto &b : outs) {
if (b.dimensions() != 2) {
Expand Down
16 changes: 8 additions & 8 deletions test/dup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ using namespace ion;
int main()
{
try {
Param v41{"v", "41"};
Param v41("v", 41);

Builder b;
b.set_target(Halide::get_host_target());
b.set_target(ion::get_host_target());
Node n;
n = b.add("test_producer").set_param(v41);
Port intm = n["output"];
n = b.add("test_inc_i32x2")(n["output"]);

PortMap pm;
Halide::Buffer<int32_t> outBuf0(std::vector<int32_t>{1, 1});
ion::Buffer<int32_t> outBuf0(std::vector<int32_t>{1, 1});
outBuf0(0, 0) = 0;
pm.set(n["output"], outBuf0);
Halide::Buffer<int32_t> outBuf1(std::vector<int32_t>{1, 1});
n["output"].bind(outBuf0);
ion::Buffer<int32_t> outBuf1(std::vector<int32_t>{1, 1});
outBuf1(0, 0) = 1;
pm.set(intm, outBuf1);
intm.bind(outBuf1);

for (int i=0; i<10; ++i) {
b.run(pm);
b.run();
if (outBuf0(0, 0) != outBuf1(0, 0)) {
std::cout << "o0:" << outBuf0(0, 0) << std::endl;
std::cout << "o1:" << outBuf1(0, 0) << std::endl;
Expand Down
28 changes: 11 additions & 17 deletions test/port-access.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ void display_image_float(Halide::Buffer<float> buffer, std::string filename) {

int main(int argc, char *argv[]) {
try {
// TODO: Test with FullHD
const int width = 200;
const int height = 150;
int width = 200;
int height = 150;

Param wparam("width", std::to_string(width));
Param hparam("height", std::to_string(height));
Param wparam("width", width);
Param hparam("height", height);

Port wport("width", Halide::type_of<int32_t>());
Port hport("height", Halide::type_of<int32_t>());
Expand All @@ -53,25 +52,20 @@ int main(int argc, char *argv[]) {
n = b.add("image_io_cameraN").set_param(
wparam,
hparam,
Param{"num_devices", "2"},
Param{"urls", "http://optipng.sourceforge.net/pngtech/img/lena.png;http://upload.wikimedia.org/wikipedia/commons/0/05/Cat.png"}
//input urls split by ';'
Param("num_devices", 2),
Param("urls", "http://optipng.sourceforge.net/pngtech/img/lena.png;http://upload.wikimedia.org/wikipedia/commons/0/05/Cat.png")
);
n = b.add("base_normalize_3d_uint8")(n["output"][1]); // access only port[1]
n = b.add("image_processing_resize_nearest_3d")(n["output"]).set_param(
Param{"width", std::to_string(width)},
Param{"height", std::to_string(height)},
Param{"scale", std::to_string(2)});
Param("width", width),
Param("height", height),
Param("scale", 2));
Port output = n["output"];

PortMap pm;

pm.set(wport, width);
pm.set(hport, height);
Halide::Buffer<float> out_buf( width, height,3);
pm.set(output, out_buf);
output.bind(out_buf);

b.run(pm);
b.run();
display_image_float(out_buf, "display.png");
std::cout << "Success" << std::endl;
} catch (const Halide::Error &e) {
Expand Down
88 changes: 0 additions & 88 deletions test/portmap-access.cc

This file was deleted.

0 comments on commit c93c641

Please sign in to comment.