Skip to content

Commit

Permalink
fix cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
xinyuli1204 committed Nov 30, 2023
1 parent 65b66d9 commit 402fa71
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 76 deletions.
19 changes: 1 addition & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ if (WITH_CUDA)
find_package(CUDA REQUIRED)
endif()





#
# Version
#
Expand Down Expand Up @@ -77,23 +73,11 @@ else()
target_link_libraries(ion-core PUBLIC Halide::Halide Halide::Runtime)
endif()


#
# SSL support to download image from url
#
if(OPENSSL_FOUND)
if (UNIX)
target_link_libraries(ion-core PUBLIC ssl crypto)
target_compile_definitions(ion-core PUBLIC CPPHTTPLIB_OPENSSL_SUPPORT)
endif()
endif()

#
# ion-bb
#
add_subdirectory(src/bb)


#
# Test
#
Expand Down Expand Up @@ -208,5 +192,4 @@ else ()
set(CPACK_GENERATOR "ZIP")
endif ()
set(CPACK_PACKAGE_VERSION ${ION_KIT_VERSION})
include(CPack)

include(CPack)
22 changes: 6 additions & 16 deletions src/bb/base/rt.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,14 @@ namespace bb {
namespace base {

std::tuple<std::string, std::string> parse_url(const std::string &url) {

const std::string https_prefix = "https://";
const std::string http_prefix = "http://";

auto prefix_length = url.rfind( https_prefix, 0) == 0 ? https_prefix.size() :
url.rfind( http_prefix, 0) == 0 ? http_prefix.size() : -1;

if (prefix_length == -1){
auto protocol_end_pos = url.find("://");
if (protocol_end_pos == std::string::npos) {
return std::tuple<std::string, std::string>("", "");
}
auto path_name_pos = url.find("/", prefix_length);
auto host_name = url.substr(prefix_length, path_name_pos-prefix_length);
auto host_name_pos = protocol_end_pos + 3;
auto path_name_pos = url.find("/", host_name_pos);
auto host_name = url.substr(0, path_name_pos);
auto path_name = url.substr(path_name_pos);

return std::tuple<std::string, std::string>(host_name, path_name);
}

Expand Down Expand Up @@ -139,12 +133,8 @@ extern "C" ION_EXPORT int ion_bb_base_buffer_loader(halide_buffer_t *url_buf, in
}
}
} else {
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
httplib::SSLClient cli(host_name.c_str());
#else
httplib::Client cli(host_name.c_str());
#endif

httplib::Client cli(host_name.c_str());
cli.set_follow_location(true);
auto res = cli.Get(path_name.c_str());
if (res && res->status == 200 && res->body.size() == size) {
Expand Down
32 changes: 7 additions & 25 deletions src/bb/image-io/rt_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,14 @@ namespace ion {
};

std::tuple<std::string, std::string> parse_url(const std::string &url) {

const std::string https_prefix = "https://";
const std::string http_prefix = "http://";

auto prefix_length = url.rfind( https_prefix, 0) == 0 ? https_prefix.size() :
url.rfind( http_prefix, 0) == 0 ? http_prefix.size() : -1;

if (prefix_length == -1){
auto protocol_end_pos = url.find("://");
if (protocol_end_pos == std::string::npos) {
return std::tuple<std::string, std::string>("", "");
}

auto path_name_pos = url.find("/", prefix_length);
auto host_name = url.substr(prefix_length, path_name_pos-prefix_length);
auto host_name_pos = protocol_end_pos + 3;
auto path_name_pos = url.find("/", host_name_pos);
auto host_name = url.substr(0, path_name_pos);
auto path_name = url.substr(path_name_pos);

return std::tuple<std::string, std::string>(host_name, path_name);
}

Expand All @@ -176,13 +169,8 @@ namespace ion {
img_loaded = true;
}
} else {
//for https url, httplib::Client throw exception (what(): 'https' scheme is not supported.). need SSL support instead
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
httplib::SSLClient cli(host_name.c_str());
#else
httplib::Client cli(host_name.c_str());
#endif

// Without CPPHTTPLIB_OPENSSL_SUPPORT pre-defined, httplib::Client throw exception (what(): 'https' scheme is not supported.).
httplib::Client cli(host_name.c_str());
cli.set_follow_location(true);
auto res = cli.Get(path_name.c_str());

Expand Down Expand Up @@ -220,13 +208,7 @@ namespace ion {
std::ifstream ifs(url, std::ios::binary);
ifs.read(reinterpret_cast<char *>(data.data()), data.size());
} else {

#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
httplib::SSLClient cli(host_name.c_str());
#else
httplib::Client cli(host_name.c_str());
#endif

cli.set_follow_location(true);
auto res = cli.Get(path_name.c_str());
if (res && res->status == 200) {
Expand Down
17 changes: 3 additions & 14 deletions src/builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ Halide::Pipeline Builder::build(const ion::PortMap& pm, std::vector<Halide::Buff
args.push_back(bb->build_input(j,f));
else{
// access to Port[index]
if (index>=fs.size()){
throw std::runtime_error("Port index out of range: " + in->name());
}
args.push_back(bb->build_input(j, fs[index]));
}

Expand Down Expand Up @@ -348,20 +351,6 @@ Halide::Pipeline Builder::build(const ion::PortMap& pm, std::vector<Halide::Buff
output_funcs.push_back(fs[i]);
outputs->push_back(kv.second[i]);
}
// if (index!=-1){
// auto fs = bbs[node_id]->get_outputs(port_key);
// output_funcs.push_back(fs[index]);
// outputs->push_back(kv.second[0]);
// }else{
// auto fs = bbs[node_id]->get_outputs(port_key);
// if (fs.size() != kv.second.size()) {
// throw std::runtime_error("Invalid size of array : " + node_id + ", " + port_key);
// }
// for (size_t i=0; i<fs.size(); ++i) {
// output_funcs.push_back(fs[i]);
// outputs->push_back(kv.second[i]);
// }
// }
} else {
auto f = bbs[node_id]->get_outputs(port_key).front();
if (1 != kv.second.size()) {
Expand Down
5 changes: 2 additions & 3 deletions test/port-access.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ void display_image_float(Halide::Buffer<float> buffer, std::string filename) {
cv::Mat img_float(height, width, CV_32F, buffer.data());
img_float.convertTo(img_out, CV_8U, 255);
}

// cv::imshow( "Display window: " + filename, img_out);
cv::imwrite("./saved.png", img_out);
cv::imshow( "Display window: " + filename, img_out);
// cv::imwrite("./saved.png", img_out);
}


Expand Down

0 comments on commit 402fa71

Please sign in to comment.