Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/port access #262

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

# Halide
mkdir ${HOME}/halide
curl -L https://github.com/halide/Halide/releases/download/v16.0.0/Halide-16.0.0-x86-64-linux-1e963ff817ef0968cc25d811a25a7350c8953ee6.tar.gz | tar zx -C ${HOME}/halide --strip-components 1
curl -L https://github.com/halide/Halide/releases/download/v17.0.1/Halide-17.0.1-x86-64-linux-52541176253e74467dabc42eeee63d9a62c199f6.tar.gz | tar zx -C ${HOME}/halide --strip-components 1
find ${HOME}/halide -type d | xargs chmod 755
sudo cp -r ${HOME}/halide/* /usr/

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
shell: bash
run: |
mkdir ${HOME}/Halide
curl -L https://github.com/halide/Halide/releases/download/v16.0.0/Halide-16.0.0-arm-64-osx-1e963ff817ef0968cc25d811a25a7350c8953ee6.tar.gz | tar zx -C ${HOME}/Halide --strip-components 1
curl -L https://github.com/halide/Halide/releases/download/v17.0.1/Halide-17.0.1-arm-64-osx-52541176253e74467dabc42eeee63d9a62c199f6.tar.gz | tar zx -C ${HOME}/Halide --strip-components 1
find ${HOME}/Halide -type d | xargs chmod 755

- name: Configure
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: |
# Halide
mkdir ${HOME}/Halide
curl -L https://github.com/halide/Halide/releases/download/v16.0.0/Halide-16.0.0-x86-64-linux-1e963ff817ef0968cc25d811a25a7350c8953ee6.tar.gz | tar zx -C ${HOME}/Halide --strip-components 1
curl -L https://github.com/halide/Halide/releases/download/v17.0.1/Halide-17.0.1-x86-64-linux-52541176253e74467dabc42eeee63d9a62c199f6.tar.gz | tar zx -C ${HOME}/Halide --strip-components 1
find ${HOME}/Halide -type d | xargs chmod 755

# zlib, libjpeg, libpng
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
run: |
# Halide
mkdir ${HOME}/Halide
curl -L https://github.com/halide/Halide/releases/download/v16.0.0/Halide-16.0.0-x86-64-windows-1e963ff817ef0968cc25d811a25a7350c8953ee6.zip -o Halide.zip
curl -L https://github.com/halide/Halide/releases/download/v17.0.1/Halide-17.0.1-x86-64-windows-52541176253e74467dabc42eeee63d9a62c199f6.zip -o Halide.zip
unzip Halide.zip
rm Halide.zip
mv Halide*/* ${HOME}/Halide
Expand Down Expand Up @@ -101,7 +101,7 @@ jobs:
shell: bash
run: |
mkdir ${HOME}/Halide
curl -L https://github.com/halide/Halide/releases/download/v16.0.0/Halide-16.0.0-arm-64-osx-1e963ff817ef0968cc25d811a25a7350c8953ee6.tar.gz | tar zx -C ${HOME}/Halide --strip-components 1
curl -L https://github.com/halide/Halide/releases/download/v17.0.1/Halide-17.0.1-arm-64-osx-52541176253e74467dabc42eeee63d9a62c199f6.tar.gz | tar zx -C ${HOME}/Halide --strip-components 1
find ${HOME}/Halide -type d | xargs chmod 755

- name: Configure
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
run: |
# Halide
mkdir ${HOME}/Halide
curl -L https://github.com/halide/Halide/releases/download/v16.0.0/Halide-16.0.0-x86-64-windows-1e963ff817ef0968cc25d811a25a7350c8953ee6.zip -o Halide.zip
curl -L https://github.com/halide/Halide/releases/download/v17.0.1/Halide-17.0.1-x86-64-windows-52541176253e74467dabc42eeee63d9a62c199f6.zip -o Halide.zip
unzip Halide.zip
rm Halide.zip
mv Halide*/* ${HOME}/Halide
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ if(UNIX)
# On unix-like system, create include unversioned symlink
# NOTE: RELEASE/DEBUG doesn't matter for the naming
get_target_property(HALIDE_SONAME Halide::Halide IMPORTED_SONAME_RELEASE)
if(APPLE)
string(REPLACE "@rpath/" "" HALIDE_SONAME ${HALIDE_SONAME})
endif()
set(HALIDE_SYMFILE ${CMAKE_BINARY_DIR}/libHalide${CMAKE_SHARED_LIBRARY_SUFFIX})
file(CREATE_LINK ${HALIDE_SONAME} ${HALIDE_SYMFILE} SYMBOLIC)
install(FILES ${HALIDE_SYMFILE} DESTINATION lib)
Expand Down
3 changes: 0 additions & 3 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ ion-core API Reference
.. doxygenclass:: ion::Node
:members:

.. doxygenclass:: ion::PortMap
:members:

.. doxygenclass:: ion::Builder
:members:

5 changes: 2 additions & 3 deletions example/fpga_dnn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ int main(int argc, char *argv[]) {

Halide::Buffer<uint8_t> out_buf(channel, width, height);

PortMap pm;
pm.set(n["output"], out_buf);
b.run(pm);
n["output"].bind(out_buf);
b.run();

cv::Mat predicted(height, width, CV_8UC3, out_buf.data());
cv::cvtColor(predicted, predicted, cv::COLOR_RGB2BGR);
Expand Down
11 changes: 5 additions & 6 deletions example/gpu_transpose.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class Transpose : public BuildingBlock<Transpose> {
GeneratorParam<std::string> gc_tags{"gc_tags", "image,camera"};
GeneratorParam<std::string> gc_inference{"gc_inference", R"((function(v){ return { output: [3, parseInt(v.width), parseInt(v.height)] }}))"};
GeneratorParam<std::string> gc_mandatory{"gc_mandatory", "width,height"};
GeneratorInput<Halide::Func> input{"input", Halide::type_of<uint8_t>(), 2};
GeneratorOutput<Halide::Func> output{"output", Halide::type_of<uint8_t>(), 2};
Input<Halide::Func> input{"input", Halide::type_of<uint8_t>(), 2};
Output<Halide::Func> output{"output", Halide::type_of<uint8_t>(), 2};

void generate() {
using namespace Halide;
Expand Down Expand Up @@ -47,11 +47,10 @@ int main() {
Port input{"input", Halide::type_of<uint8_t>(), 2};
auto n = b.add("transpose")(input);

PortMap pm;
pm.set(input, ibuf);
pm.set(n["output"], obuf);
input.bind(ibuf);
n["output"].bind(obuf);

b.run(pm);
b.run();

} catch (const std::exception &e) {
std::cerr << e.what() << std::endl;
Expand Down
8 changes: 4 additions & 4 deletions example/opencv_bb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ int main(int argc, char *argv[]) {

Halide::Buffer<int32_t> r = Halide::Buffer<int32_t>::make_scalar();

PortMap pm;
pm.set(in, in_buf);
pm.set(n["output"], r);

in.bind(in_buf);
n["output"].bind(r);

for (int i=0; i<1000; ++i) {
b.run(pm);
b.run();
}

} catch (const std::exception &e) {
Expand Down
66 changes: 45 additions & 21 deletions example/u3v.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,37 @@

using namespace ion;

struct rawHeader {

// ---------- 0
int version_;
// ---------- 4
int width_;
int height_;
// ---------- 12
float r_gain0_;
float g_gain0_;
float b_gain0_;
// ---------- 24
float r_gain1_;
float g_gain1_;
float b_gain1_;
// ---------- 36
int offset0_x_;
int offset0_y_;
int offset1_x_;
int offset1_y_;
// ---------- 52
int outputsize0_x_;
int outputsize0_y_;
int outputsize1_x_;
int outputsize1_y_;
// ---------- 68
float fps_;
// ---------- 72
int pfnc_pixelformat;
};

void display_and_save(int32_t width, int32_t height, std::string directory_path, rawHeader header_info, bool last_run){

Builder b;
Expand Down Expand Up @@ -115,28 +146,27 @@ void display_and_save(int32_t width, int32_t height, std::string directory_path,
Param{"height", std::to_string(height)});
Port display_output1_p = n["output"];

PortMap pm;
/* input */
pm.set(wp, width);
pm.set(hp, height);

pm.set(r_gain0_p, header_info.r_gain0_);
pm.set(g_gain0_p, header_info.g_gain0_);
pm.set(b_gain0_p, header_info.b_gain0_);
/* input */
wp.bind(&width);
hp.bind(&height);

pm.set(r_gain1_p, header_info.r_gain1_);
pm.set(g_gain1_p, header_info.g_gain1_);
pm.set(b_gain1_p, header_info.b_gain1_);
r_gain0_p.bind(&header_info.r_gain0_);
g_gain0_p.bind(&header_info.g_gain0_);
b_gain0_p.bind(&header_info.b_gain0_);

r_gain1_p.bind(&header_info.r_gain1_);
g_gain1_p.bind(&header_info.g_gain1_);
b_gain1_p.bind(&header_info.b_gain1_);

/* output */
Halide::Buffer<int> out0 = Halide::Buffer<int>::make_scalar();
Halide::Buffer<int> out1 = Halide::Buffer<int>::make_scalar();
pm.set(display_output0_p, out0);
pm.set(display_output1_p, out1);
display_output0_p.bind(out0);
display_output1_p.bind(out1);

Halide::Buffer<int32_t> out = Halide::Buffer<int32_t>::make_scalar();
pm.set(terminator, out);
terminator.bind(out);

int32_t gain0 = 0;
int32_t gain1 = 480;
Expand All @@ -146,19 +176,13 @@ void display_and_save(int32_t width, int32_t height, std::string directory_path,
int loop_num = 400;

for (int i=0; i< loop_num; ++i) {
pm.set(dispose_camera, last_run && i == loop_num - 1);
pm.set(dispose_writer, i == loop_num - 1);
pm.set(gain0_p, gain0++);
pm.set(gain1_p, gain1--);
pm.set(exposure0_p, exposure0);
pm.set(exposure1_p, exposure1);
b.run(pm);
b.run();
}

cv::destroyAllWindows();
}

void open_and_check(int32_t& width, int32_t& height, const filesystem::path output_directory, uint32_t& file_idx, std::ifstream& ifs, bool *finished) {
void open_and_check(int32_t& width, int32_t& height, const std::filesystem::path output_directory, uint32_t& file_idx, std::ifstream& ifs, bool *finished) {
auto file_path = output_directory / ("raw-" + ::std::to_string(file_idx++) + ".bin");

ifs = ::std::ifstream(file_path, ::std::ios::binary);
Expand Down
3 changes: 1 addition & 2 deletions include/ion/builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "graph.h"
#include "node.h"
#include "target.h"
#include "port_map.h"

namespace ion {

Expand Down Expand Up @@ -96,7 +95,7 @@ class Builder {
* @arg pm: This remains just for backward compatibility. Port::bind can be used instead of PortMap.
* This argument will be removed in coming major release.
*/
void run(const PortMap& pm = PortMap());
void run();

/**
* Retrieve names of BBs
Expand Down
1 change: 0 additions & 1 deletion include/ion/ion.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "node.h"
#include "param.h"
#include "port.h"
#include "port_map.h"
#include "target.h"
#include "type.h"

Expand Down
14 changes: 7 additions & 7 deletions include/ion/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Port {
Halide::Type type;
int32_t dimensions;

std::unordered_map<uint32_t, Halide::Internal::Parameter> params;
std::unordered_map<uint32_t, Halide::Parameter> params;
std::unordered_map<uint32_t, const void *> instances;

Impl();
Expand Down Expand Up @@ -181,9 +181,9 @@ class Port {
void bind(T *v) {
auto i = index_ == -1 ? 0 : index_;
if (has_pred()) {
impl_->params[i] = Halide::Internal::Parameter{Halide::type_of<T>(), false, 0, argument_name(pred_id(), pred_name(), i, graph_id())};
impl_->params[i] = Halide::Parameter{Halide::type_of<T>(), false, 0, argument_name(pred_id(), pred_name(), i, graph_id())};
} else {
impl_->params[i] = Halide::Internal::Parameter{type(), false, dimensions(), argument_name(pred_id(), pred_name(), i, graph_id())};
impl_->params[i] = Halide::Parameter{type(), false, dimensions(), argument_name(pred_id(), pred_name(), i, graph_id())};
}

impl_->instances[i] = v;
Expand All @@ -193,9 +193,9 @@ class Port {
void bind(const Halide::Buffer<T>& buf) {
auto i = index_ == -1 ? 0 : index_;
if (has_pred()) {
impl_->params[i] = Halide::Internal::Parameter{buf.type(), true, buf.dimensions(), argument_name(pred_id(), pred_name(), i,graph_id())};
impl_->params[i] = Halide::Parameter{buf.type(), true, buf.dimensions(), argument_name(pred_id(), pred_name(), i,graph_id())};
} else {
impl_->params[i] = Halide::Internal::Parameter{type(), true, dimensions(), argument_name(pred_id(), pred_name(), i,graph_id())};
impl_->params[i] = Halide::Parameter{type(), true, dimensions(), argument_name(pred_id(), pred_name(), i,graph_id())};
}

impl_->instances[i] = buf.raw_buffer();
Expand All @@ -205,9 +205,9 @@ class Port {
void bind(const std::vector<Halide::Buffer<T>>& bufs) {
for (int i=0; i<static_cast<int>(bufs.size()); ++i) {
if (has_pred()) {
impl_->params[i] = Halide::Internal::Parameter{bufs[i].type(), true, bufs[i].dimensions(), argument_name(pred_id(), pred_name(), i, graph_id())};
impl_->params[i] = Halide::Parameter{bufs[i].type(), true, bufs[i].dimensions(), argument_name(pred_id(), pred_name(), i, graph_id())};
} else {
impl_->params[i] = Halide::Internal::Parameter{type(), true, dimensions(), argument_name(pred_id(), pred_name(), i, graph_id())};
impl_->params[i] = Halide::Parameter{type(), true, dimensions(), argument_name(pred_id(), pred_name(), i, graph_id())};
}

impl_->instances[i] = bufs[i].raw_buffer();
Expand Down
43 changes: 0 additions & 43 deletions include/ion/port_map.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/bb/sgm/bb.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Halide::Func disparity(Halide::Func cost, int32_t disp) {

Func g("argmin");
g(x, y) = Tuple(0, (e.type().max)());
g(x, y) = tuple_select(e < g(x, y)[1], Tuple(r, e), g(x, y));
g(x, y) = select(e < g(x, y)[1], Tuple(r, e), g(x, y));

g.update().unroll(r[0]);

Expand Down
2 changes: 1 addition & 1 deletion src/builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void Builder::compile(const std::string& function_name, const CompileOption& opt
return;
}

void Builder::run(const ion::PortMap&) {
void Builder::run() {
if (!impl_->pipeline.defined()) {
impl_->pipeline = lower(*this, impl_->nodes, false);
if (!impl_->pipeline.defined()) {
Expand Down
Loading
Loading