From b6b1c63c3a473cc22a031ff4036af359e9b323c1 Mon Sep 17 00:00:00 2001 From: xinyuli1204 Date: Wed, 29 Nov 2023 18:30:38 -0800 Subject: [PATCH 01/11] fix parse_url and add port index access --- CMakeLists.txt | 66 +++-- example/demo.json | 1 + example/gender_count.cc | 15 +- include/ion/port.h | 29 ++- include/ion/port_map.h | 17 +- src/bb/base/rt.h | 29 ++- src/bb/image-io/bb.h | 162 +++++++++++++ src/bb/image-io/rt_common.h | 468 +++++++++++++++++++----------------- src/builder.cc | 26 +- test/CMakeLists.txt | 10 + test/port-access.cc | 84 +++++++ 11 files changed, 624 insertions(+), 283 deletions(-) create mode 100644 example/demo.json create mode 100644 test/port-access.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index affc35c3..d1a88ba9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,9 +6,9 @@ cmake_minimum_required(VERSION 3.6) # Options # if (UNIX) - set(DEFAULT_TARGET_BB "base;dnn;image-io;image-processing;opencv;sgm") + set(DEFAULT_TARGET_BB "base;dnn;image-io;image-processing;opencv;sgm") else() - set(DEFAULT_TARGET_BB "base;image-io;image-processing;opencv;sgm") + set(DEFAULT_TARGET_BB "base;image-io;image-processing;opencv;sgm") endif() set(ION_TARGET_BB ${DEFAULT_TARGET_BB} CACHE STRING "A List of building blocks to build (This overrides ION_BUILD_ALL_BB)") option(ION_BUILD_DOC "Build documents." OFF) @@ -41,12 +41,12 @@ endif() # Version # execute_process(COMMAND git describe --tags - OUTPUT_VARIABLE GIT_DESCRIBE_RESULT - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + OUTPUT_VARIABLE GIT_DESCRIBE_RESULT + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) message(STATUS "Version: ${GIT_DESCRIBE_RESULT}") string(STRIP "${GIT_DESCRIBE_RESULT}" ION_KIT_VERSION_S) add_definitions("-DION_KIT_VERSION=\"${ION_KIT_VERSION_S}\"") -string(REPLACE "v" "" ION_KIT_VERSION ${ION_KIT_VERSION_S}) +string(REPLACE "v" "" ION_KIT_VERSION "${ION_KIT_VERSION_S}") file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/VERSION CONTENT "${ION_KIT_VERSION_S}") # @@ -68,9 +68,9 @@ file(GLOB ION_CORE_SRC LIST_DIRECTORIES false ${PROJECT_SOURCE_DIR}/src/*) add_library(ion-core SHARED ${ION_CORE_SRC}) target_include_directories(ion-core PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/src) if (UNIX) - target_link_libraries(ion-core PUBLIC Halide::Halide Halide::Runtime dl pthread z) + target_link_libraries(ion-core PUBLIC Halide::Halide Halide::Runtime dl pthread z) else() - target_link_libraries(ion-core PUBLIC Halide::Halide Halide::Runtime) + target_link_libraries(ion-core PUBLIC Halide::Halide Halide::Runtime) endif() # @@ -82,6 +82,19 @@ add_subdirectory(src/bb) # Test # if (ION_BUILD_TEST) + find_package(OpenSSL REQUIRED) + if(OPENSSL_FOUND) + set(HTTPLIB_IS_USING_OPENSSL TRUE) + endif() + if (UNIX) + target_link_libraries(ion-core PUBLIC + $<$:OpenSSL::SSL> + $<$:OpenSSL::Crypto>) + + target_compile_definitions(ion-core PUBLIC + $<$:CPPHTTPLIB_OPENSSL_SUPPORT> + ) + endif() enable_testing() add_subdirectory(test) endif() @@ -105,19 +118,19 @@ if (ION_BUILD_DOC) list(APPEND PUBLIC_HEADERS ${FILES}) set(DOXYGEN_INDEX_FILE ${CMAKE_BINARY_DIR}/xml/index.xml) add_custom_command(OUTPUT ${DOXYGEN_INDEX_FILE} - COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_SOURCE_DIR}/doc/Doxyfile - DEPENDS ${PUBLIC_HEADERS} - MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/doc/Doxyfile - COMMENT "Generating docs") + COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_SOURCE_DIR}/doc/Doxyfile + DEPENDS ${PUBLIC_HEADERS} + MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/doc/Doxyfile + COMMENT "Generating docs") add_custom_target(Doxygen ALL DEPENDS ${DOXYGEN_INDEX_FILE}) set(SPHINX_INDEX_FILE ${CMAKE_BINARY_DIR}/doc/index.html) add_custom_command(OUTPUT ${SPHINX_INDEX_FILE} - COMMAND ${SPHINX_EXECUTABLE} -b html - -Dbreathe_projects.ion-core=${CMAKE_BINARY_DIR}/xml - ${CMAKE_SOURCE_DIR}/doc ${CMAKE_BINARY_DIR}/doc - DEPENDS ${DOXYGEN_INDEX_FILE} - MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/doc/index.rst) + COMMAND ${SPHINX_EXECUTABLE} -b html + -Dbreathe_projects.ion-core=${CMAKE_BINARY_DIR}/xml + ${CMAKE_SOURCE_DIR}/doc ${CMAKE_BINARY_DIR}/doc + DEPENDS ${DOXYGEN_INDEX_FILE} + MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/doc/index.rst) add_custom_target(Sphinx ALL DEPENDS ${SPHINX_INDEX_FILE}) install(DIRECTORY ${CMAKE_BINARY_DIR}/doc DESTINATION .) @@ -141,14 +154,14 @@ endif() install(DIRECTORY include DESTINATION .) install(FILES - ${CMAKE_BINARY_DIR}/VERSION - DESTINATION .) + ${CMAKE_BINARY_DIR}/VERSION + DESTINATION .) install(FILES - ${CMAKE_SOURCE_DIR}/LICENSE - DESTINATION license) + ${CMAKE_SOURCE_DIR}/LICENSE + DESTINATION license) install(FILES - ${CMAKE_SOURCE_DIR}/thirdparty_notice.txt - DESTINATION license) + ${CMAKE_SOURCE_DIR}/thirdparty_notice.txt + DESTINATION license) # Halide if (ION_BUNDLE_HALIDE) @@ -158,10 +171,10 @@ if (ION_BUNDLE_HALIDE) install(FILES ${HALIDE_HEADERS} DESTINATION include) file(GLOB HALIDE_BINS - ${HALIDE_ROOT}/bin/featurization_to_sample* - ${HALIDE_ROOT}/bin/get_host_target* - ${HALIDE_ROOT}/bin/retrain_cost_model* - ${HALIDE_ROOT}/bin/weightsdir_to_weightsfile*) + ${HALIDE_ROOT}/bin/featurization_to_sample* + ${HALIDE_ROOT}/bin/get_host_target* + ${HALIDE_ROOT}/bin/retrain_cost_model* + ${HALIDE_ROOT}/bin/weightsdir_to_weightsfile*) install(FILES ${HALIDE_BINS} DESTINATION bin) install(DIRECTORY ${HALIDE_ROOT}/lib/cmake/Halide DESTINATION lib/cmake/) @@ -193,3 +206,4 @@ else () endif () set(CPACK_PACKAGE_VERSION ${ION_KIT_VERSION}) include(CPack) + diff --git a/example/demo.json b/example/demo.json new file mode 100644 index 00000000..5b0b9fa0 --- /dev/null +++ b/example/demo.json @@ -0,0 +1 @@ +{"nodes":[{"id":"45e8e54e-f6c1-4773-a196-c4d064a84430","name":"image_io_imx219","params":[{"key_":"index","val_":"0"},{"key_":"url","val_":"http://ion-kit.s3.us-west-2.amazonaws.com/images/pedestrian.jpg"}],"ports":[],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"4d84f5b5-8681-4d8c-a33b-c4eddaac3582","name":"image_processing_bayer_downscale_uint16","params":[{"key_":"input_width","val_":"3264"},{"key_":"input_height","val_":"2464"},{"key_":"downscale_factor","val_":"2"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"45e8e54e-f6c1-4773-a196-c4d064a84430","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"a4a521ea-c11d-4388-9c16-9ee9942a996f","name":"image_processing_normalize_raw_image","params":[{"key_":"bit_width","val_":"10"},{"key_":"bit_shift","val_":"6"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"4d84f5b5-8681-4d8c-a33b-c4eddaac3582","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"8e5a9cf7-03c2-4fe3-aedc-a7c9cb019270","name":"image_processing_bayer_offset","params":[],"ports":[{"dimensions_":0,"key_":"offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"a4a521ea-c11d-4388-9c16-9ee9942a996f","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"0949c5f1-20e9-4561-a9ad-f41fbfa5c358","name":"image_processing_lens_shading_correction_linear","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"shading_correction_slope_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"8e5a9cf7-03c2-4fe3-aedc-a7c9cb019270","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"2cdc6187-38b3-491d-a775-8e8351755f89","name":"image_processing_bayer_white_balance","params":[],"ports":[{"dimensions_":0,"key_":"gain_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"0949c5f1-20e9-4561-a9ad-f41fbfa5c358","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"0c37914d-72f7-41a0-b6e4-2922fe1643bc","name":"image_processing_bayer_demosaic_simple","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"2cdc6187-38b3-491d-a775-8e8351755f89","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"baf959c0-83dd-40bb-b5a9-6dfe7678710b","name":"image_processing_resize_bilinear_3d","params":[{"key_":"width","val_":"816"},{"key_":"height","val_":"616"},{"key_":"scale","val_":"0.675325"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"0c37914d-72f7-41a0-b6e4-2922fe1643bc","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"bc477a80-470d-4777-bca6-fea3e06bcf0b","name":"image_processing_gamma_correction_3d","params":[],"ports":[{"dimensions_":0,"key_":"gamma","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"baf959c0-83dd-40bb-b5a9-6dfe7678710b","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"ecb40056-ef5e-4e18-8b01-90b7d27cff5a","name":"image_processing_fit_image_to_center_3d_float","params":[{"key_":"input_width","val_":"551"},{"key_":"input_height","val_":"416"},{"key_":"output_width","val_":"416"},{"key_":"output_height","val_":"416"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"bc477a80-470d-4777-bca6-fea3e06bcf0b","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"421d163d-4a3b-4a6a-b768-5a8a44c8a29e","name":"image_processing_reorder_color_channel_3d_float","params":[],"ports":[{"dimensions_":0,"key_":"output","node_id_":"ecb40056-ef5e-4e18-8b01-90b7d27cff5a","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"f2397b04-dc1d-43fa-863c-f75152bcd3dd","name":"base_reorder_buffer_3d_float","params":[{"key_":"dim0","val_":"2"},{"key_":"dim1","val_":"0"},{"key_":"dim2","val_":"1"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"421d163d-4a3b-4a6a-b768-5a8a44c8a29e","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"85680ab8-90d4-423e-90c8-f8a524413621","name":"base_extend_dimension_3d_float","params":[{"key_":"new_dim","val_":"3"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"f2397b04-dc1d-43fa-863c-f75152bcd3dd","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"9b6f084c-152a-43b9-87af-85e044c8a90b","name":"image_io_imx219","params":[{"key_":"index","val_":"1"},{"key_":"url","val_":"http://ion-kit.s3.us-west-2.amazonaws.com/images/pedestrian.jpg"}],"ports":[],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"f4e1dcd0-95e3-4708-9f17-5d27c28c26c9","name":"image_processing_bayer_downscale_uint16","params":[{"key_":"input_width","val_":"3264"},{"key_":"input_height","val_":"2464"},{"key_":"downscale_factor","val_":"2"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"9b6f084c-152a-43b9-87af-85e044c8a90b","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"fb54bc78-5085-45d6-acf9-96aedd836c2e","name":"image_processing_normalize_raw_image","params":[{"key_":"bit_width","val_":"10"},{"key_":"bit_shift","val_":"6"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"f4e1dcd0-95e3-4708-9f17-5d27c28c26c9","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"831e8731-07bf-4aa9-a782-b3fb06a8677c","name":"image_processing_bayer_offset","params":[],"ports":[{"dimensions_":0,"key_":"offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"fb54bc78-5085-45d6-acf9-96aedd836c2e","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"de62a886-4464-4017-b4e0-2bdc607c681a","name":"image_processing_lens_shading_correction_linear","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"shading_correction_slope_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"831e8731-07bf-4aa9-a782-b3fb06a8677c","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"fc866d17-ba6f-439c-bf39-9183349eeee6","name":"image_processing_bayer_white_balance","params":[],"ports":[{"dimensions_":0,"key_":"gain_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"de62a886-4464-4017-b4e0-2bdc607c681a","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"30381bff-250e-4ede-a59c-3b089beedff7","name":"image_processing_bayer_demosaic_simple","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"fc866d17-ba6f-439c-bf39-9183349eeee6","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"ea8b69e9-62e3-4a8a-b4d3-3d7083e14dd2","name":"image_processing_resize_bilinear_3d","params":[{"key_":"width","val_":"816"},{"key_":"height","val_":"616"},{"key_":"scale","val_":"0.675325"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"30381bff-250e-4ede-a59c-3b089beedff7","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"38c4ad28-7150-411d-928c-dc20ba8e69ff","name":"image_processing_gamma_correction_3d","params":[],"ports":[{"dimensions_":0,"key_":"gamma","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"ea8b69e9-62e3-4a8a-b4d3-3d7083e14dd2","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"8e54dbe1-de37-49d3-8bd8-fe2a527512fe","name":"image_processing_fit_image_to_center_3d_float","params":[{"key_":"input_width","val_":"551"},{"key_":"input_height","val_":"416"},{"key_":"output_width","val_":"416"},{"key_":"output_height","val_":"416"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"38c4ad28-7150-411d-928c-dc20ba8e69ff","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"0d5ab5c3-e6fb-4537-ab83-2ad3b48583d4","name":"image_processing_reorder_color_channel_3d_float","params":[],"ports":[{"dimensions_":0,"key_":"output","node_id_":"8e54dbe1-de37-49d3-8bd8-fe2a527512fe","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"12a3604a-eba4-42fd-806a-58a26638c070","name":"base_reorder_buffer_3d_float","params":[{"key_":"dim0","val_":"2"},{"key_":"dim1","val_":"0"},{"key_":"dim2","val_":"1"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"0d5ab5c3-e6fb-4537-ab83-2ad3b48583d4","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"27da41b6-7b11-4c31-a50f-0503b66b7cc9","name":"base_extend_dimension_3d_float","params":[{"key_":"new_dim","val_":"3"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"12a3604a-eba4-42fd-806a-58a26638c070","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"169603c5-ec1e-465d-8369-971bd15a034d","name":"image_io_imx219","params":[{"key_":"index","val_":"2"},{"key_":"url","val_":"http://ion-kit.s3.us-west-2.amazonaws.com/images/pedestrian.jpg"}],"ports":[],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"38a54ec9-8b54-49d6-a02e-87f16c029f79","name":"image_processing_bayer_downscale_uint16","params":[{"key_":"input_width","val_":"3264"},{"key_":"input_height","val_":"2464"},{"key_":"downscale_factor","val_":"2"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"169603c5-ec1e-465d-8369-971bd15a034d","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"03a04682-663b-455f-96cf-26045402c238","name":"image_processing_normalize_raw_image","params":[{"key_":"bit_width","val_":"10"},{"key_":"bit_shift","val_":"6"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"38a54ec9-8b54-49d6-a02e-87f16c029f79","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"b848ae23-07be-424f-a5b5-5a38077246ac","name":"image_processing_bayer_offset","params":[],"ports":[{"dimensions_":0,"key_":"offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"03a04682-663b-455f-96cf-26045402c238","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"287a10a6-b5d6-4dc7-a786-5c338ba3405b","name":"image_processing_lens_shading_correction_linear","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"shading_correction_slope_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"b848ae23-07be-424f-a5b5-5a38077246ac","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"0255726c-9072-48fe-98f4-60db25d5663f","name":"image_processing_bayer_white_balance","params":[],"ports":[{"dimensions_":0,"key_":"gain_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"287a10a6-b5d6-4dc7-a786-5c338ba3405b","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"07b71554-d047-47f9-899f-59533abcd4b6","name":"image_processing_bayer_demosaic_simple","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"0255726c-9072-48fe-98f4-60db25d5663f","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"aa0b89ef-0d72-47bb-9d37-703432d67d95","name":"image_processing_resize_bilinear_3d","params":[{"key_":"width","val_":"816"},{"key_":"height","val_":"616"},{"key_":"scale","val_":"0.675325"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"07b71554-d047-47f9-899f-59533abcd4b6","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"a3dbc1a7-427b-4bba-9b0d-00eeae596ad7","name":"image_processing_gamma_correction_3d","params":[],"ports":[{"dimensions_":0,"key_":"gamma","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"aa0b89ef-0d72-47bb-9d37-703432d67d95","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"6cbd6c80-6407-4ea5-8e44-4f61903e85bf","name":"image_processing_fit_image_to_center_3d_float","params":[{"key_":"input_width","val_":"551"},{"key_":"input_height","val_":"416"},{"key_":"output_width","val_":"416"},{"key_":"output_height","val_":"416"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"a3dbc1a7-427b-4bba-9b0d-00eeae596ad7","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"683c978c-e009-4602-9d35-6ca527399204","name":"image_processing_reorder_color_channel_3d_float","params":[],"ports":[{"dimensions_":0,"key_":"output","node_id_":"6cbd6c80-6407-4ea5-8e44-4f61903e85bf","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"21eee05c-695e-4f07-b98b-2721ea9409fb","name":"base_reorder_buffer_3d_float","params":[{"key_":"dim0","val_":"2"},{"key_":"dim1","val_":"0"},{"key_":"dim2","val_":"1"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"683c978c-e009-4602-9d35-6ca527399204","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"27c2599d-0c87-475c-a13f-cacf755ef5bb","name":"base_extend_dimension_3d_float","params":[{"key_":"new_dim","val_":"3"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"21eee05c-695e-4f07-b98b-2721ea9409fb","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"81600864-b92a-499a-8352-d25f37379693","name":"image_io_imx219","params":[{"key_":"index","val_":"3"},{"key_":"url","val_":"http://ion-kit.s3.us-west-2.amazonaws.com/images/pedestrian.jpg"}],"ports":[],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"ec422fab-aef4-4faf-b1af-d2b381349349","name":"image_processing_bayer_downscale_uint16","params":[{"key_":"input_width","val_":"3264"},{"key_":"input_height","val_":"2464"},{"key_":"downscale_factor","val_":"2"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"81600864-b92a-499a-8352-d25f37379693","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"a18db56a-1c77-42d5-915f-c1b1cef9cafd","name":"image_processing_normalize_raw_image","params":[{"key_":"bit_width","val_":"10"},{"key_":"bit_shift","val_":"6"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"ec422fab-aef4-4faf-b1af-d2b381349349","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"2cdeec19-4258-46a6-ad96-ec2156182c5f","name":"image_processing_bayer_offset","params":[],"ports":[{"dimensions_":0,"key_":"offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"a18db56a-1c77-42d5-915f-c1b1cef9cafd","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"76f749de-4f56-4fbe-8233-cb6e0fb3bf61","name":"image_processing_lens_shading_correction_linear","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"shading_correction_slope_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"2cdeec19-4258-46a6-ad96-ec2156182c5f","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"e152f687-b96d-4c70-892a-79b2da0877fb","name":"image_processing_bayer_white_balance","params":[],"ports":[{"dimensions_":0,"key_":"gain_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"76f749de-4f56-4fbe-8233-cb6e0fb3bf61","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"704a5e2f-64c2-45e2-976f-73fd46da8f03","name":"image_processing_bayer_demosaic_simple","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"e152f687-b96d-4c70-892a-79b2da0877fb","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"547cecfa-4650-441d-9197-e036569818e4","name":"image_processing_resize_bilinear_3d","params":[{"key_":"width","val_":"816"},{"key_":"height","val_":"616"},{"key_":"scale","val_":"0.675325"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"704a5e2f-64c2-45e2-976f-73fd46da8f03","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"951e7112-1825-4570-bbf1-9e0bd45bd7b1","name":"image_processing_gamma_correction_3d","params":[],"ports":[{"dimensions_":0,"key_":"gamma","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"547cecfa-4650-441d-9197-e036569818e4","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"5c5a130b-962f-4d67-b2eb-3c350fe32b5f","name":"image_processing_fit_image_to_center_3d_float","params":[{"key_":"input_width","val_":"551"},{"key_":"input_height","val_":"416"},{"key_":"output_width","val_":"416"},{"key_":"output_height","val_":"416"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"951e7112-1825-4570-bbf1-9e0bd45bd7b1","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"2bf497c9-0e42-4fda-a921-8c288309d14f","name":"image_processing_reorder_color_channel_3d_float","params":[],"ports":[{"dimensions_":0,"key_":"output","node_id_":"5c5a130b-962f-4d67-b2eb-3c350fe32b5f","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"5a4b0e14-3433-45aa-82ae-27978a4ab5db","name":"base_reorder_buffer_3d_float","params":[{"key_":"dim0","val_":"2"},{"key_":"dim1","val_":"0"},{"key_":"dim2","val_":"1"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"2bf497c9-0e42-4fda-a921-8c288309d14f","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"aa4cbf6f-3b35-4252-b750-08df5548d1bc","name":"base_extend_dimension_3d_float","params":[{"key_":"new_dim","val_":"3"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"5a4b0e14-3433-45aa-82ae-27978a4ab5db","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"0133307e-4ce2-4dd2-9f0d-1f0154008ef9","name":"image_io_imx219","params":[{"key_":"index","val_":"4"},{"key_":"url","val_":"http://ion-kit.s3.us-west-2.amazonaws.com/images/pedestrian.jpg"}],"ports":[],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"f5625498-32f8-4c83-b59b-ce5e9024e890","name":"image_processing_bayer_downscale_uint16","params":[{"key_":"input_width","val_":"3264"},{"key_":"input_height","val_":"2464"},{"key_":"downscale_factor","val_":"2"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"0133307e-4ce2-4dd2-9f0d-1f0154008ef9","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"992c3b4e-9d7c-4ec6-915a-881bcc4cde6e","name":"image_processing_normalize_raw_image","params":[{"key_":"bit_width","val_":"10"},{"key_":"bit_shift","val_":"6"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"f5625498-32f8-4c83-b59b-ce5e9024e890","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"1dddae9d-2f0e-4fb0-b2f0-ae12831af25b","name":"image_processing_bayer_offset","params":[],"ports":[{"dimensions_":0,"key_":"offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"992c3b4e-9d7c-4ec6-915a-881bcc4cde6e","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"cbd2f319-a4a5-4ebc-a37e-78d5b8f170be","name":"image_processing_lens_shading_correction_linear","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"shading_correction_slope_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"1dddae9d-2f0e-4fb0-b2f0-ae12831af25b","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"e849bfe5-d044-4259-924c-094f3fe6bbdd","name":"image_processing_bayer_white_balance","params":[],"ports":[{"dimensions_":0,"key_":"gain_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"cbd2f319-a4a5-4ebc-a37e-78d5b8f170be","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"c5166dd4-484f-4a42-b314-f5fdcca3020f","name":"image_processing_bayer_demosaic_simple","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"e849bfe5-d044-4259-924c-094f3fe6bbdd","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"79d02637-f784-44cc-b51a-a88ccba696ee","name":"image_processing_resize_bilinear_3d","params":[{"key_":"width","val_":"816"},{"key_":"height","val_":"616"},{"key_":"scale","val_":"0.675325"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"c5166dd4-484f-4a42-b314-f5fdcca3020f","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"f1d5a826-2eae-460e-939f-b0aa3cefe4e6","name":"image_processing_gamma_correction_3d","params":[],"ports":[{"dimensions_":0,"key_":"gamma","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"79d02637-f784-44cc-b51a-a88ccba696ee","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"a19c9d5b-d7d1-4d72-9385-112db53862e7","name":"image_processing_fit_image_to_center_3d_float","params":[{"key_":"input_width","val_":"551"},{"key_":"input_height","val_":"416"},{"key_":"output_width","val_":"416"},{"key_":"output_height","val_":"416"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"f1d5a826-2eae-460e-939f-b0aa3cefe4e6","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"bbbf59c5-594e-43cf-b56b-b487169334b6","name":"image_processing_reorder_color_channel_3d_float","params":[],"ports":[{"dimensions_":0,"key_":"output","node_id_":"a19c9d5b-d7d1-4d72-9385-112db53862e7","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"a03e6319-1195-465f-bfa9-3c4903a7ab04","name":"base_reorder_buffer_3d_float","params":[{"key_":"dim0","val_":"2"},{"key_":"dim1","val_":"0"},{"key_":"dim2","val_":"1"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"bbbf59c5-594e-43cf-b56b-b487169334b6","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"74b06c2e-1444-45f7-946a-7ca9c46d1ccf","name":"base_extend_dimension_3d_float","params":[{"key_":"new_dim","val_":"3"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"a03e6319-1195-465f-bfa9-3c4903a7ab04","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"88d385a3-bb2c-4ee9-8b5e-0b7fed1f1eec","name":"image_io_imx219","params":[{"key_":"index","val_":"5"},{"key_":"url","val_":"http://ion-kit.s3.us-west-2.amazonaws.com/images/pedestrian.jpg"}],"ports":[],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"898e1443-6033-4c5a-9547-ac465fad65f9","name":"image_processing_bayer_downscale_uint16","params":[{"key_":"input_width","val_":"3264"},{"key_":"input_height","val_":"2464"},{"key_":"downscale_factor","val_":"2"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"88d385a3-bb2c-4ee9-8b5e-0b7fed1f1eec","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"17b555f8-b3b2-48fb-8b73-f1c770df4ab1","name":"image_processing_normalize_raw_image","params":[{"key_":"bit_width","val_":"10"},{"key_":"bit_shift","val_":"6"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"898e1443-6033-4c5a-9547-ac465fad65f9","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"85a9a5ef-4434-4905-b6b0-1dc10ba65be7","name":"image_processing_bayer_offset","params":[],"ports":[{"dimensions_":0,"key_":"offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"17b555f8-b3b2-48fb-8b73-f1c770df4ab1","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"b2f02255-2c93-49ff-b3df-b05f651acd5d","name":"image_processing_lens_shading_correction_linear","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"shading_correction_slope_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"85a9a5ef-4434-4905-b6b0-1dc10ba65be7","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"147dd3b7-7106-447b-add6-31521cde5a3b","name":"image_processing_bayer_white_balance","params":[],"ports":[{"dimensions_":0,"key_":"gain_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"b2f02255-2c93-49ff-b3df-b05f651acd5d","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"40081848-a1f8-4eb2-9f4d-968423dffe1d","name":"image_processing_bayer_demosaic_simple","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"147dd3b7-7106-447b-add6-31521cde5a3b","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"12892599-3ccb-4ea1-a983-0c91ec4ebeb0","name":"image_processing_resize_bilinear_3d","params":[{"key_":"width","val_":"816"},{"key_":"height","val_":"616"},{"key_":"scale","val_":"0.675325"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"40081848-a1f8-4eb2-9f4d-968423dffe1d","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"48dc330b-03d9-4218-b7b9-c43273e5ac77","name":"image_processing_gamma_correction_3d","params":[],"ports":[{"dimensions_":0,"key_":"gamma","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"12892599-3ccb-4ea1-a983-0c91ec4ebeb0","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"6d9c0949-1002-4b61-bf89-cbce120459bb","name":"image_processing_fit_image_to_center_3d_float","params":[{"key_":"input_width","val_":"551"},{"key_":"input_height","val_":"416"},{"key_":"output_width","val_":"416"},{"key_":"output_height","val_":"416"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"48dc330b-03d9-4218-b7b9-c43273e5ac77","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"d747c7a2-b65c-4cfc-97ba-c083cbe9a694","name":"image_processing_reorder_color_channel_3d_float","params":[],"ports":[{"dimensions_":0,"key_":"output","node_id_":"6d9c0949-1002-4b61-bf89-cbce120459bb","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"cab19bfa-82ff-46be-b941-1f35421bca79","name":"base_reorder_buffer_3d_float","params":[{"key_":"dim0","val_":"2"},{"key_":"dim1","val_":"0"},{"key_":"dim2","val_":"1"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"d747c7a2-b65c-4cfc-97ba-c083cbe9a694","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"38e35fd6-dc63-4726-bfe4-a64edca0a7a6","name":"base_extend_dimension_3d_float","params":[{"key_":"new_dim","val_":"3"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"cab19bfa-82ff-46be-b941-1f35421bca79","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"1b71a8d5-b5b2-489d-a790-ca54b30d553f","name":"base_concat_buffer_4d_float","params":[{"key_":"dim","val_":"3"},{"key_":"input0_extent","val_":"1"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"85680ab8-90d4-423e-90c8-f8a524413621","type_":{"bits":0,"code":3,"lanes":0}},{"dimensions_":0,"key_":"output","node_id_":"27da41b6-7b11-4c31-a50f-0503b66b7cc9","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"10bd31ac-7884-4763-99e1-d69e494f736a","name":"base_concat_buffer_4d_float","params":[{"key_":"dim","val_":"3"},{"key_":"input0_extent","val_":"2"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"1b71a8d5-b5b2-489d-a790-ca54b30d553f","type_":{"bits":0,"code":3,"lanes":0}},{"dimensions_":0,"key_":"output","node_id_":"27c2599d-0c87-475c-a13f-cacf755ef5bb","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"e548d112-0843-46f5-a51a-0d44c2d79d64","name":"base_concat_buffer_4d_float","params":[{"key_":"dim","val_":"3"},{"key_":"input0_extent","val_":"3"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"10bd31ac-7884-4763-99e1-d69e494f736a","type_":{"bits":0,"code":3,"lanes":0}},{"dimensions_":0,"key_":"output","node_id_":"aa4cbf6f-3b35-4252-b750-08df5548d1bc","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"73b4ee3c-4a24-458f-a49e-de803349f826","name":"base_concat_buffer_4d_float","params":[{"key_":"dim","val_":"3"},{"key_":"input0_extent","val_":"4"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"e548d112-0843-46f5-a51a-0d44c2d79d64","type_":{"bits":0,"code":3,"lanes":0}},{"dimensions_":0,"key_":"output","node_id_":"74b06c2e-1444-45f7-946a-7ca9c46d1ccf","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"cacd780c-a1dd-43fb-b9bf-c38814c4c91b","name":"base_concat_buffer_4d_float","params":[{"key_":"dim","val_":"3"},{"key_":"input0_extent","val_":"5"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"73b4ee3c-4a24-458f-a49e-de803349f826","type_":{"bits":0,"code":3,"lanes":0}},{"dimensions_":0,"key_":"output","node_id_":"38e35fd6-dc63-4726-bfe4-a64edca0a7a6","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"10f8a75f-c20a-499a-bfd4-70cec095a98c","name":"dnn_object_detection_array","params":[],"ports":[{"dimensions_":0,"key_":"output","node_id_":"cacd780c-a1dd-43fb-b9bf-c38814c4c91b","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"4d8fa9bf-2be2-487d-93dc-90e6d1c569a2","name":"base_extract_buffer_4d_float","params":[{"key_":"dim","val_":"3"},{"key_":"index","val_":"0"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"10f8a75f-c20a-499a-bfd4-70cec095a98c","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"bd181b36-c377-4e45-a195-98191b011fa7","name":"base_extract_buffer_4d_float","params":[{"key_":"dim","val_":"3"},{"key_":"index","val_":"1"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"10f8a75f-c20a-499a-bfd4-70cec095a98c","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"d7db2cb0-53ad-4138-b124-24f85982444f","name":"base_extract_buffer_4d_float","params":[{"key_":"dim","val_":"3"},{"key_":"index","val_":"2"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"10f8a75f-c20a-499a-bfd4-70cec095a98c","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"4836b891-086a-406c-a182-3db0e306c6b6","name":"base_extract_buffer_4d_float","params":[{"key_":"dim","val_":"3"},{"key_":"index","val_":"3"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"10f8a75f-c20a-499a-bfd4-70cec095a98c","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"1f5c4689-0861-45ae-ad7a-44ea37032d67","name":"base_extract_buffer_4d_float","params":[{"key_":"dim","val_":"3"},{"key_":"index","val_":"4"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"10f8a75f-c20a-499a-bfd4-70cec095a98c","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"dff76dac-1edf-4ed0-8ec5-3fbb9932461f","name":"base_extract_buffer_4d_float","params":[{"key_":"dim","val_":"3"},{"key_":"index","val_":"5"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"10f8a75f-c20a-499a-bfd4-70cec095a98c","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"66be5b19-16ad-4ef6-9c8c-9a156a654854","name":"image_processing_tile_image_horizontal_3d_float","params":[{"key_":"x_dim","val_":"1"},{"key_":"y_dim","val_":"2"},{"key_":"input0_width","val_":"416"},{"key_":"input0_height","val_":"416"},{"key_":"input1_width","val_":"416"},{"key_":"input1_height","val_":"416"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"4d8fa9bf-2be2-487d-93dc-90e6d1c569a2","type_":{"bits":0,"code":3,"lanes":0}},{"dimensions_":0,"key_":"output","node_id_":"bd181b36-c377-4e45-a195-98191b011fa7","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"6333e7f5-2af8-4f97-ad12-55d67d4e7990","name":"image_processing_tile_image_horizontal_3d_float","params":[{"key_":"x_dim","val_":"1"},{"key_":"y_dim","val_":"2"},{"key_":"input0_width","val_":"832"},{"key_":"input0_height","val_":"416"},{"key_":"input1_width","val_":"416"},{"key_":"input1_height","val_":"416"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"66be5b19-16ad-4ef6-9c8c-9a156a654854","type_":{"bits":0,"code":3,"lanes":0}},{"dimensions_":0,"key_":"output","node_id_":"d7db2cb0-53ad-4138-b124-24f85982444f","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"89bb4d07-44d5-4ac7-9fb4-fe214c129524","name":"image_processing_tile_image_horizontal_3d_float","params":[{"key_":"x_dim","val_":"1"},{"key_":"y_dim","val_":"2"},{"key_":"input0_width","val_":"416"},{"key_":"input0_height","val_":"416"},{"key_":"input1_width","val_":"416"},{"key_":"input1_height","val_":"416"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"4836b891-086a-406c-a182-3db0e306c6b6","type_":{"bits":0,"code":3,"lanes":0}},{"dimensions_":0,"key_":"output","node_id_":"1f5c4689-0861-45ae-ad7a-44ea37032d67","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"203fb938-51c8-4a3e-b2b1-959794ca8acf","name":"image_processing_tile_image_horizontal_3d_float","params":[{"key_":"x_dim","val_":"1"},{"key_":"y_dim","val_":"2"},{"key_":"input0_width","val_":"832"},{"key_":"input0_height","val_":"416"},{"key_":"input1_width","val_":"416"},{"key_":"input1_height","val_":"416"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"89bb4d07-44d5-4ac7-9fb4-fe214c129524","type_":{"bits":0,"code":3,"lanes":0}},{"dimensions_":0,"key_":"output","node_id_":"dff76dac-1edf-4ed0-8ec5-3fbb9932461f","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"7fa4fbf5-9a3c-4bed-af69-970505bab97d","name":"image_processing_tile_image_vertical_3d_float","params":[{"key_":"x_dim","val_":"1"},{"key_":"y_dim","val_":"2"},{"key_":"input0_width","val_":"1248"},{"key_":"input0_height","val_":"416"},{"key_":"input1_width","val_":"1248"},{"key_":"input1_height","val_":"416"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"6333e7f5-2af8-4f97-ad12-55d67d4e7990","type_":{"bits":0,"code":3,"lanes":0}},{"dimensions_":0,"key_":"output","node_id_":"203fb938-51c8-4a3e-b2b1-959794ca8acf","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"b9876919-7bfa-46dc-89f0-e5e77cdb08a4","name":"base_denormalize_3d_uint8","params":[],"ports":[{"dimensions_":0,"key_":"output","node_id_":"7fa4fbf5-9a3c-4bed-af69-970505bab97d","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"85049eb5-f05b-4784-82c1-8fcfc62d88bb","name":"image_io_d435","params":[],"ports":[],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"addc321d-7c3e-4fe1-9450-cfc5feeeb850","name":"sgm_sgm","params":[{"key_":"disp","val_":"16"},{"key_":"width","val_":"1280"},{"key_":"height","val_":"720"}],"ports":[{"dimensions_":0,"key_":"output_l","node_id_":"85049eb5-f05b-4784-82c1-8fcfc62d88bb","type_":{"bits":0,"code":3,"lanes":0}},{"dimensions_":0,"key_":"output_r","node_id_":"85049eb5-f05b-4784-82c1-8fcfc62d88bb","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"} \ No newline at end of file diff --git a/example/gender_count.cc b/example/gender_count.cc index 2a4ca9ff..b8a01609 100644 --- a/example/gender_count.cc +++ b/example/gender_count.cc @@ -25,26 +25,15 @@ int main(int argc, char *argv[]) { n = b.add("base_reorder_buffer_3d_float")(n["output"]).set_param(Param{"dim0", "2"}, Param{"dim1", "0"}, Param{"dim2", "1"}); // CHW -> HWC auto img = n["output"]; - n = b.add("dnn_tlt_peoplenet")(img); - n = b.add("base_reorder_buffer_3d_float")(n["output"]).set_param(Param{"dim0", "1"}, Param{"dim1", "2"}, Param{"dim2", "0"}); // HWC -> CHW - n = b.add("base_denormalize_3d_uint8")(n["output"]); - n = b.add("image_io_gui_display")(n["output"]).set_param(wparam, hparam); Port out_p1 = n["output"]; - n = b.add("dnn_tlt_peoplenet_md")(img).set_param(wparam, hparam); - n = b.add("dnn_classify_gender")(img, n["output"]).set_param(wparam, hparam); - n = b.add("dnn_json_dict_average_regulator")(n["output"]).set_param(Param{"period_in_sec", "10"}); - n = b.add("dnn_ifttt_webhook_uploader")(n["output"]).set_param(Param{"ifttt_webhook_url", "http://maker.ifttt.com/trigger/gender_count/with/key/buf--6AoUjTGu868Pva_Q9"}); - Port out_p2 = n["output"]; - PortMap pm; pm.set(wport, width); pm.set(hport, height); Halide::Buffer out1 = Halide::Buffer::make_scalar(); pm.set(out_p1, out1); - Halide::Buffer out2 = Halide::Buffer::make_scalar(); - pm.set(out_p2, out2); - for (int i=0; i<1000; ++i) { + + for (int i=0; i<10; ++i) { b.run(pm); } } catch (const std::exception &e) { diff --git a/include/ion/port.h b/include/ion/port.h index a9da7a46..cf16c33b 100644 --- a/include/ion/port.h +++ b/include/ion/port.h @@ -147,7 +147,7 @@ class Port { friend class Node; Port() - : key_(), type_(), dimensions_(0), node_id_(), param_info_() {} + : key_(), type_(), dimensions_(0), index_(-1), node_id_(), param_info_() {} /** * Construct new port for scalar value. @@ -155,7 +155,7 @@ class Port { * @arg t: The type of the value. */ Port(const std::string& k, Halide::Type t) - : key_(k), type_(t), dimensions_(0), node_id_(), param_info_(new ParamContainer(k, t)) {} + : key_(k), type_(t), dimensions_(0), index_(-1), node_id_(), param_info_(new ParamContainer(k, t)) {} /** * Construct new port for vector value. @@ -164,7 +164,7 @@ class Port { * @arg d: The dimension of the port. The range is 1 to 4. */ Port(const std::string& k, Halide::Type t, int32_t d) - : key_(k), type_(t), dimensions_(d), node_id_(), param_info_(new ParamContainer(k, t, d)) {} + : key_(k), type_(t), dimensions_(d), index_(-1), node_id_(), param_info_(new ParamContainer(k, t, d)) {} std::string key() const { return key_; } std::string& key() { return key_; } @@ -175,6 +175,9 @@ class Port { int32_t dimensions() const { return dimensions_; } int32_t& dimensions() { return dimensions_; } + int32_t index() const { return index_; } + int32_t& index() { return index_; } + std::string node_id() const { return node_id_; } std::string& node_id() { return node_id_; } @@ -203,15 +206,25 @@ class Port { return !node_id_.empty(); } - private: - /** - * This port is bound with some node. - */ - Port(const std::string& k, const std::string& ni) : key_(k), type_(), dimensions_(0), node_id_(ni), param_info_(nullptr){} + + /** + * Overloaded operator to set the port index and return a reference to the current port. eg. port[0] + */ + Port operator[](int i) { + this->index_ = i; + return *this; + } + +private: + /** + * This port is bound with some node. + */ + Port(const std::string& k, const std::string& ni) : key_(k), type_(), index_(-1), dimensions_(0), node_id_(ni), param_info_(nullptr){} std::string key_; Halide::Type type_; int32_t dimensions_; + int32_t index_; std::string node_id_; std::shared_ptr param_info_; }; diff --git a/include/ion/port_map.h b/include/ion/port_map.h index c6c4c3e8..27259ee0 100644 --- a/include/ion/port_map.h +++ b/include/ion/port_map.h @@ -127,10 +127,21 @@ class PortMap { void set(Port p, const std::vector> &bufs) { if (p.bound()) { // This is just an output. +// if (p.index()!=-1){ +// for (size_t i=0; i=buf.size()){ +// throw std::invalid_argument( +// "Port index is out of range"); +// } + + output_buffer_[std::make_tuple(p.node_id(), p.key())].push_back(bufs[p.index()]); + +// } + - for (size_t i=0; i parse_url(const std::string &url) { - if (url.rfind("http://", 0) != 0) { // not starts_with - return std::tuple("", ""); + std::tuple 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){ + return std::tuple("", ""); + } + auto path_name_pos = url.find("/", prefix_length); + auto host_name = url.substr(prefix_length, path_name_pos-prefix_length); + auto path_name = url.substr(path_name_pos); + + return std::tuple(host_name, path_name); } - auto path_name_pos = url.find("/", 7); - auto host_name = url.substr(0, path_name_pos); - auto path_name = url.substr(path_name_pos); - return std::tuple(host_name, path_name); -} template void fill_by_rng(std::mt19937 &rng, halide_buffer_t *range, halide_buffer_t *out) { @@ -131,7 +139,12 @@ 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 + cli.set_follow_location(true); auto res = cli.Get(path_name.c_str()); if (res && res->status == 200 && res->body.size() == size) { diff --git a/src/bb/image-io/bb.h b/src/bb/image-io/bb.h index 1a475403..fed6b9c2 100644 --- a/src/bb/image-io/bb.h +++ b/src/bb/image-io/bb.h @@ -243,6 +243,164 @@ class Camera : public ion::BuildingBlock { } }; +class Camera2 : public ion::BuildingBlock { +public: + GeneratorParam num_devices{"num_devices", 2}; + GeneratorParam gc_title{"gc_title", "USBCamera"}; + GeneratorParam gc_description{"gc_description", "This captures USB camera image."}; + GeneratorParam gc_tags{"gc_tags", "input,sensor"}; + GeneratorParam gc_inference{"gc_inference", R"((function(v){ return { output: [parseInt(v.width), parseInt(v.height), 3] }}))"}; + GeneratorParam gc_mandatory{"gc_mandatory", "width,height"}; + GeneratorParam gc_strategy{"gc_strategy", "self"}; + GeneratorParam gc_prefix{"gc_prefix", ""}; + + GeneratorParam fps{"fps", 30}; + GeneratorParam width{"width", 0}; + GeneratorParam height{"height", 0}; + GeneratorParam index{"index", 0}; + GeneratorParam url0{"url0", ""}; + GeneratorParam url1{"url1", ""}; + + + + GeneratorOutput output0{"output0", Halide::type_of(), 3}; + GeneratorOutput output1{"output1", Halide::type_of(), 3}; + + + void generate() { + using namespace Halide; + + + for (int i =0; i < num_devices; i++){ + std::string url_str; + if(i == 0){ + url_str = url0; + } + else{ + url_str = url1; + } + + Halide::Buffer url_buf(url_str.size() + 1); + url_buf.fill(0); + std::memcpy(url_buf.data(), url_str.c_str(), url_str.size()); + + std::vector params = {instance_id++, cast(index), cast(fps), cast(width), cast(height), url_buf}; + Func camera(static_cast(gc_prefix) + "camera"); + camera.define_extern("ion_bb_image_io_camera", params, Halide::type_of(), 2); + camera.compute_root(); + + Func camera_ = BoundaryConditions::repeat_edge(camera, {{0, 2 * width}, {0, height}}); + + Var c, x, y; + + Expr yv = cast(camera_(2 * x, y)); + Expr uv = cast(camera_(select((x & 1) == 0, 2 * x + 1, 2 * x - 1), y)); + Expr vv = cast(camera_(select((x & 1) == 0, 2 * x + 3, 2 * x + 1), y)); + + Expr f128 = cast(128); + Expr r = saturating_cast(yv + cast(1.403f) * (vv - f128)); + Expr g = saturating_cast(yv - cast(0.344f) * (uv - f128) - (cast(0.714f) * (vv - f128))); + Expr b = saturating_cast(yv + cast(1.773f) * (uv - f128)); + + + + + Func f(static_cast(gc_prefix) + "output" + std::to_string(i)); + f(x, y, c) = mux(c, {r, g, b}); + + + if (i ==0) + output0 = f; + else + output1 = f; + } + + } +}; + + + +class CameraN : public ion::BuildingBlock { + public: + GeneratorParam num_devices{"num_devices", 2}; + GeneratorParam gc_title{"gc_title", "USBCamera"}; + GeneratorParam gc_description{"gc_description", "This captures USB camera image."}; + GeneratorParam gc_tags{"gc_tags", "input,sensor"}; + GeneratorParam gc_inference{"gc_inference", R"((function(v){ return { output: [parseInt(v.width), parseInt(v.height), 3] }}))"}; + GeneratorParam gc_mandatory{"gc_mandatory", "width,height"}; + GeneratorParam gc_strategy{"gc_strategy", "self"}; + GeneratorParam gc_prefix{"gc_prefix", ""}; + + GeneratorParam fps{"fps", 30}; + GeneratorParam width{"width", 0}; + GeneratorParam height{"height", 0}; + GeneratorParam index{"index", 0}; + GeneratorParam urls{"urls", ""}; + +// GeneratorInput[]> urls{"urls"}; + GeneratorOutput output{"output", Halide::type_of(), 3}; + + + void generate() { + + std::stringstream urls_stream(urls); + std::string url; + std::vector url_list; + while(std::getline(urls_stream, url, ';')) + { + url_list.push_back(url); + } + + + using namespace Halide; + + output.resize(num_devices); + + for (int i =0; i < num_devices; i++){ + std::string url_str; + if (url_list.size()!=0){ + url_str = url_list[i]; + } + else{ + url_str = ""; + } + + + + Halide::Buffer url_buf(url_str.size() + 1); + url_buf.fill(0); + std::memcpy(url_buf.data(), url_str.c_str(), url_str.size()); + + std::vector params = {instance_id++, cast(index), cast(fps), cast(width), cast(height), url_buf}; + Func camera(static_cast(gc_prefix) + "camera"); + camera.define_extern("ion_bb_image_io_camera", params, Halide::type_of(), 2); + camera.compute_root(); + + Func camera_ = BoundaryConditions::repeat_edge(camera, {{0, 2 * width}, {0, height}}); + + Var c, x, y; + + Expr yv = cast(camera_(2 * x, y)); + Expr uv = cast(camera_(select((x & 1) == 0, 2 * x + 1, 2 * x - 1), y)); + Expr vv = cast(camera_(select((x & 1) == 0, 2 * x + 3, 2 * x + 1), y)); + + Expr f128 = cast(128); + Expr r = saturating_cast(yv + cast(1.403f) * (vv - f128)); + Expr g = saturating_cast(yv - cast(0.344f) * (uv - f128) - (cast(0.714f) * (vv - f128))); + Expr b = saturating_cast(yv + cast(1.773f) * (uv - f128)); + + + Func f(static_cast(gc_prefix) + "output" + std::to_string(i)); + f(x, y, c) = mux(c, {r, g, b}); + + output[i](_) = f(_); + } + + } +}; + + + class GenericV4L2Bayer : public ion::BuildingBlock { public: GeneratorParam gc_title{"gc_title", "GenericV4L2Bayer"}; @@ -1087,7 +1245,11 @@ class BinaryLoader : public ion::BuildingBlock { #ifndef _WIN32 ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::IMX219, image_io_imx219); ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::D435, image_io_d435); + ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::Camera, image_io_camera); +ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::Camera2, image_io_camera2); +ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::CameraN, image_io_cameraN); + ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::GenericV4L2Bayer, image_io_generic_v4l2_bayer); ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::CameraSimulation, image_io_camera_simulation); ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::FBDisplay, image_io_fb_display); diff --git a/src/bb/image-io/rt_common.h b/src/bb/image-io/rt_common.h index a4ffc01b..3c8e0d61 100644 --- a/src/bb/image-io/rt_common.h +++ b/src/bb/image-io/rt_common.h @@ -14,6 +14,8 @@ #include #endif + + #include "httplib.h" #include "zip_file.hpp" @@ -31,34 +33,34 @@ #endif namespace ion { -namespace bb { -namespace image_io { - -template -std::string format(const char *fmt, const Rest &... rest) { - int length = snprintf(NULL, 0, fmt, rest...) + 1; // Explicit place for null termination - std::vector buf(length, 0); - snprintf(&buf[0], length, fmt, rest...); - std::string s(buf.begin(), std::find(buf.begin(), buf.end(), '\0')); - return s; -} - -class DynamicModule { -public: + namespace bb { + namespace image_io { + + template + std::string format(const char *fmt, const Rest &... rest) { + int length = snprintf(NULL, 0, fmt, rest...) + 1; // Explicit place for null termination + std::vector buf(length, 0); + snprintf(&buf[0], length, fmt, rest...); + std::string s(buf.begin(), std::find(buf.begin(), buf.end(), '\0')); + return s; + } + + class DynamicModule { + public: #ifdef _WIN32 - using Handle = HMODULE; + using Handle = HMODULE; #else - using Handle = void *; + using Handle = void *; #endif - DynamicModule(const std::string &module_name, bool essential) { - if (module_name == "") { - handle_ = nullptr; - return; - } + DynamicModule(const std::string &module_name, bool essential) { + if (module_name == "") { + handle_ = nullptr; + return; + } #ifdef _WIN32 - auto file_name = module_name + ".dll"; + auto file_name = module_name + ".dll"; handle_ = LoadLibraryA(file_name.c_str()); if (handle_ != nullptr){ @@ -70,52 +72,52 @@ class DynamicModule { handle_ = LoadLibraryA(file_name.c_str()); #else - auto file_name = "lib" + module_name + ".so"; - handle_ = dlopen(file_name.c_str(), RTLD_NOW); + auto file_name = "lib" + module_name + ".so"; + handle_ = dlopen(file_name.c_str(), RTLD_NOW); #endif - if (handle_ == nullptr) { - if (essential) { - throw std::runtime_error(get_error_string()); - } else { - std::cerr << format("WARNING: Not found the not essential dynamic library: %s, it may work as a simulation mode", module_name.c_str()); - } - } - } + if (handle_ == nullptr) { + if (essential) { + throw std::runtime_error(get_error_string()); + } else { + std::cerr << format("WARNING: Not found the not essential dynamic library: %s, it may work as a simulation mode", module_name.c_str()); + } + } + } - ~DynamicModule() { - if (handle_ != nullptr) { + ~DynamicModule() { + if (handle_ != nullptr) { #ifdef _WIN32 - FreeLibrary(handle_); + FreeLibrary(handle_); #else - dlclose(handle_); + dlclose(handle_); #endif - } - } + } + } - DynamicModule(const std::string &module_name) - : DynamicModule(module_name, true) { - } + DynamicModule(const std::string &module_name) + : DynamicModule(module_name, true) { + } - bool is_available(void) const { - return handle_ != NULL; - } + bool is_available(void) const { + return handle_ != NULL; + } - template - T get_symbol(const std::string &symbol_name) const { + template + T get_symbol(const std::string &symbol_name) const { #if defined(_WIN32) - return reinterpret_cast(GetProcAddress(handle_, symbol_name.c_str())); + return reinterpret_cast(GetProcAddress(handle_, symbol_name.c_str())); #else - return reinterpret_cast(dlsym(handle_, symbol_name.c_str())); + return reinterpret_cast(dlsym(handle_, symbol_name.c_str())); #endif - } + } -private: - std::string get_error_string(void) const { - std::string error_msg; + private: + std::string get_error_string(void) const { + std::string error_msg; #ifdef _WIN32 - LPVOID lpMsgBuf; + LPVOID lpMsgBuf; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, GetLastError(), @@ -128,194 +130,212 @@ class DynamicModule { error_msg.assign(buf.begin(), buf.end()); LocalFree(lpMsgBuf); #else - const char *buf(dlerror()); - error_msg.assign(buf ? buf : "none"); + const char *buf(dlerror()); + error_msg.assign(buf ? buf : "none"); #endif - return error_msg; - } - - Handle handle_; -}; - -std::tuple parse_url(const std::string &url) { - if (url.rfind("http://", 0) != 0) { // not starts_with - return std::tuple("", ""); - } - auto path_name_pos = url.find("/", 7); - auto host_name = url.substr(0, path_name_pos); - auto path_name = url.substr(path_name_pos); - return std::tuple(host_name, path_name); -} + return error_msg; + } -#ifndef _WIN32 -cv::Mat get_image(const std::string &url) { - if (url.empty()) { - return {}; - } - - std::string host_name; - std::string path_name; - std::tie(host_name, path_name) = parse_url(url); - - cv::Mat img; - bool img_loaded = false; - if (host_name.empty() || path_name.empty()) { - // fallback to local file - img = cv::imread(url); - if (!img.empty()) { - img_loaded = true; - } - } else { - 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) { - std::vector data(res->body.size()); - std::memcpy(data.data(), res->body.c_str(), res->body.size()); - img = cv::imdecode(cv::InputArray(data), cv::IMREAD_COLOR); - if (!img.empty()) { - img_loaded = true; - } - } - } - - if (img_loaded) { - return img; - } else { - return {}; - } -} - -class ImageSequence { - - public: - ImageSequence(const std::string& session_id, const std::string& url) : idx_(0) { - namespace fs = std::filesystem; - - std::string host_name; - std::string path_name; - std::tie(host_name, path_name) = ion::bb::image_io::parse_url(url); - - std::vector data; - if (host_name.empty() || path_name.empty()) { - // fallback to local file - data.resize(fs::file_size(url)); - std::ifstream ifs(url, std::ios::binary); - ifs.read(reinterpret_cast(data.data()), data.size()); - } else { - 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) { - data.resize(res->body.size()); - std::memcpy(data.data(), res->body.c_str(), res->body.size()); - } else { - throw std::runtime_error("Failed to download"); + Handle handle_; + }; + + std::tuple 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){ + return std::tuple("", ""); + } + + auto path_name_pos = url.find("/", prefix_length); + auto host_name = url.substr(prefix_length, path_name_pos-prefix_length); + auto path_name = url.substr(path_name_pos); + + return std::tuple(host_name, path_name); } - } - auto dir_path = fs::temp_directory_path() / session_id; - if (!fs::exists(dir_path)) { - if (!fs::create_directory(dir_path)) { - throw std::runtime_error("Failed to create temporary directory"); +#ifndef _WIN32 + cv::Mat get_image(const std::string &url) { + if (url.empty()) { + return {}; + } + + std::string host_name; + std::string path_name; + std::tie(host_name, path_name) = parse_url(url); + cv::Mat img; + bool img_loaded = false; + if (host_name.empty() || path_name.empty()) { + // fallback to local file + img = cv::imread(url); + if (!img.empty()) { + img_loaded = true; + } + } 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) { + std::vector data(res->body.size()); + std::memcpy(data.data(), res->body.c_str(), res->body.size()); + img = cv::imdecode(cv::InputArray(data), cv::IMREAD_COLOR); + if (!img.empty()) { + img_loaded = true; + } + } + } + + if (img_loaded) { + return img; + } else { + return {}; + } } - } - if (fs::path(url).extension() == ".zip") { - miniz_cpp::zip_file zf(data); - zf.extractall(dir_path.string()); - } else { - std::ofstream ofs(dir_path / fs::path(url).filename(), std::ios::binary); - ofs.write(reinterpret_cast(data.data()), data.size()); - } + class ImageSequence { - for (auto& d : fs::directory_iterator(dir_path)) { - paths_.push_back(d.path()); - } - // Dictionary order - std::sort(paths_.begin(), paths_.end()); + public: + ImageSequence(const std::string& session_id, const std::string& url) : idx_(0) { + namespace fs = std::filesystem; - } + std::string host_name; + std::string path_name; + std::tie(host_name, path_name) = ion::bb::image_io::parse_url(url); - cv::Mat get(int width, int height, int imread_flags) { - namespace fs = std::filesystem; + std::vector data; + if (host_name.empty() || path_name.empty()) { + // fallback to local file + data.resize(fs::file_size(url)); + std::ifstream ifs(url, std::ios::binary); + ifs.read(reinterpret_cast(data.data()), data.size()); + } else { - cv::Mat frame; +#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) { + data.resize(res->body.size()); + std::memcpy(data.data(), res->body.c_str(), res->body.size()); + } else { + throw std::runtime_error("Failed to download"); + } + } - auto path = paths_[idx_]; + auto dir_path = fs::temp_directory_path() / session_id; + if (!fs::exists(dir_path)) { + if (!fs::create_directory(dir_path)) { + throw std::runtime_error("Failed to create temporary directory"); + } + } - if (path.extension() == ".raw") { - auto size = fs::file_size(path); - switch (imread_flags) { - case cv::IMREAD_GRAYSCALE: - if (size == width * height * sizeof(uint8_t)) { - frame = cv::Mat(height, width, CV_8UC1); - } else if (size == width * height * sizeof(uint16_t)) { - frame = cv::Mat(height, width, CV_16UC1); + if (fs::path(url).extension() == ".zip") { + miniz_cpp::zip_file zf(data); + zf.extractall(dir_path.string()); } else { - throw std::runtime_error("Unsupported raw format"); + std::ofstream ofs(dir_path / fs::path(url).filename(), std::ios::binary); + ofs.write(reinterpret_cast(data.data()), data.size()); } - break; - case cv::IMREAD_COLOR: - if (size == 3 * width * height * sizeof(uint8_t)) { - // Expect interleaved RGB - frame = cv::Mat(height, width, CV_8UC3); + + for (auto& d : fs::directory_iterator(dir_path)) { + paths_.push_back(d.path()); + } + // Dictionary order + std::sort(paths_.begin(), paths_.end()); + + } + + cv::Mat get(int width, int height, int imread_flags) { + namespace fs = std::filesystem; + + cv::Mat frame; + auto path = paths_[idx_]; + if (path.extension() == ".raw") { + auto size = fs::file_size(path); + switch (imread_flags) { + case cv::IMREAD_GRAYSCALE: + if (size == width * height * sizeof(uint8_t)) { + frame = cv::Mat(height, width, CV_8UC1); + } else if (size == width * height * sizeof(uint16_t)) { + frame = cv::Mat(height, width, CV_16UC1); + } else { + throw std::runtime_error("Unsupported raw format"); + } + break; + case cv::IMREAD_COLOR: + if (size == 3 * width * height * sizeof(uint8_t)) { + // Expect interleaved RGB + frame = cv::Mat(height, width, CV_8UC3); + } else { + throw std::runtime_error("Unsupported raw format"); + } + break; + default: + throw std::runtime_error("Unsupported flags"); + } + std::ifstream ifs(path, std::ios::binary); + ifs.read(reinterpret_cast(frame.ptr()), size); } else { - throw std::runtime_error("Unsupported raw format"); + frame = cv::imread(path.string(), imread_flags); + if (frame.empty()) { + throw std::runtime_error("Failed to load data : " + path.string()); + } } - break; - default: - throw std::runtime_error("Unsupported flags"); - } - std::ifstream ifs(path, std::ios::binary); - ifs.read(reinterpret_cast(frame.ptr()), size); - } else { - frame = cv::imread(path.string(), imread_flags); - if (frame.empty()) { - throw std::runtime_error("Failed to load data : " + path.string()); - } - } - idx_ = ((idx_+1) % paths_.size()); + idx_ = ((idx_+1) % paths_.size()); - return frame; - } + return frame; + } - private: - int32_t idx_; - std::vector paths_; -}; + private: + int32_t idx_; + std::vector paths_; + }; #endif // _WIN32 -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; -}; + 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; + }; // PFNC // https://www.emva.org/wp-content/uploads/GenICamPixelFormatValues.pdf @@ -325,8 +345,8 @@ struct rawHeader { #define PFNC_RGB8 0x02180014 #define PFNC_BGR8 0x02180015 -} // namespace image_io -} // namespace bb + } // namespace image_io + } // namespace bb } // namespace ion -#endif +#endif \ No newline at end of file diff --git a/src/builder.cc b/src/builder.cc index 4e4842d0..d55d297e 100644 --- a/src/builder.cc +++ b/src/builder.cc @@ -254,6 +254,7 @@ Halide::Pipeline Builder::build(const ion::PortMap& pm, std::vector> args; for (size_t j=0; jparam_info().inputs().at(j); if (p.node_id().empty()) { @@ -308,7 +309,16 @@ Halide::Pipeline Builder::build(const ion::PortMap& pm, std::vectorbuild_input(j, f())); } else if (in->kind() == Internal::IOKind::Function) { - args.push_back(bb->build_input(j, f)); + auto fs =bbs[p.node_id()]->get_outputs(p.key()); + // no specific index provided, direct output Port + if (index == -1) + args.push_back(bb->build_input(j,f)); + else{ + // access to Port[index] + args.push_back(bb->build_input(j, fs[index])); + } + + } else { throw std::runtime_error("fixme"); } @@ -338,6 +348,20 @@ Halide::Pipeline Builder::build(const ion::PortMap& pm, std::vectorpush_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; ipush_back(kv.second[i]); +// } +// } } else { auto f = bbs[node_id]->get_outputs(port_key).front(); if (1 != kv.second.size()) { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e8823c39..8d0894a0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,6 +2,9 @@ # ion-core Testing # + + + # Test BB module add_library(ion-bb-test SHARED ion-bb-test.cc) if(UNIX) @@ -59,11 +62,18 @@ ion_jit(dup SRCS dup.cc) add_dependencies(dup ion-bb-test) ion_register_test(dup_test dup) + # Output error handling ion_jit(port-binding SRCS port-binding.cc) add_dependencies(port-binding ion-bb-test) ion_register_test(port-binding_test port-binding) +# Port index access +ion_jit(port-access SRCS port-access.cc) +add_dependencies(port-access ion-bb-test) +ion_register_test(port-access_test port-access) + + ion_jit(direct-extern SRCS direct-extern.cc) add_dependencies(direct-extern ion-bb-test) ion_register_test(direct-extern_test direct-extern) diff --git a/test/port-access.cc b/test/port-access.cc new file mode 100644 index 00000000..6565c0fb --- /dev/null +++ b/test/port-access.cc @@ -0,0 +1,84 @@ +#include +#include + +// to display +#include +#include +#include + + +using namespace ion; + +void display_image_float(Halide::Buffer buffer, std::string filename) { + int width = buffer.width(); + int height = buffer.height(); + int channels = buffer.channels(); + cv::Mat img_out; + if (channels == 3) { + cv::Mat img_float; + cv::merge(std::vector{ + cv::Mat(height, width, CV_32F, buffer.data() + width * height * 2), + cv::Mat(height, width, CV_32F, buffer.data() + width * height * 1), + cv::Mat(height, width, CV_32F, buffer.data())}, + img_float); + img_float.convertTo(img_out, CV_8U, 255); + } else { + 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); +} + + +int main(int argc, char *argv[]) { + try { + // TODO: Test with FullHD + const int width = 200; + const int height = 150; + + Param wparam("width", std::to_string(width)); + Param hparam("height", std::to_string(height)); + + Port wport("width", Halide::type_of()); + Port hport("height", Halide::type_of()); + + Builder b; + b.set_target(Halide::get_target_from_environment()); + b.with_bb_module("ion-bb"); + + Node n; + n = b.add("image_io_cameraN").set_param( + wparam, + hparam, + Param{"num_devices", "2"}, + Param{"urls", "http://optipng.sourceforge.net/pngtech/img/lena.png;https://upload.wikimedia.org/wikipedia/commons/0/05/Cat.png"} + //input urls split by ';' + ); + n = b.add("base_normalize_3d_uint8")(n["output"][0]); // 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)}); + Port output = n["output"]; + + PortMap pm; + + pm.set(wport, width); + pm.set(hport, height); + Halide::Buffer out_buf( width, height,3); + pm.set(output, out_buf); + + b.run(pm); + display_image_float(out_buf, "display.png"); + std::cout << "Success" << std::endl; + } catch (const std::exception &e) { + std::cerr << e.what() << std::endl; + return -1; + } catch (...) { + return -1; + } + + return 0; +} From 65b66d9eff8f12cce26462f1b9ce4b2d25222c90 Mon Sep 17 00:00:00 2001 From: xinyuli1204 Date: Thu, 30 Nov 2023 09:46:32 -0800 Subject: [PATCH 02/11] fix parse url and add intermidiate port index access --- CMakeLists.txt | 29 ++++++++++++++++------------- example/demo.json | 1 - src/bb/image-io/rt_common.h | 1 + test/port-access.cc | 6 +++--- 4 files changed, 20 insertions(+), 17 deletions(-) delete mode 100644 example/demo.json diff --git a/CMakeLists.txt b/CMakeLists.txt index d1a88ba9..616e314c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,10 @@ if (WITH_CUDA) find_package(CUDA REQUIRED) endif() + + + + # # Version # @@ -73,28 +77,27 @@ 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 # if (ION_BUILD_TEST) - find_package(OpenSSL REQUIRED) - if(OPENSSL_FOUND) - set(HTTPLIB_IS_USING_OPENSSL TRUE) - endif() - if (UNIX) - target_link_libraries(ion-core PUBLIC - $<$:OpenSSL::SSL> - $<$:OpenSSL::Crypto>) - - target_compile_definitions(ion-core PUBLIC - $<$:CPPHTTPLIB_OPENSSL_SUPPORT> - ) - endif() enable_testing() add_subdirectory(test) endif() diff --git a/example/demo.json b/example/demo.json deleted file mode 100644 index 5b0b9fa0..00000000 --- a/example/demo.json +++ /dev/null @@ -1 +0,0 @@ -{"nodes":[{"id":"45e8e54e-f6c1-4773-a196-c4d064a84430","name":"image_io_imx219","params":[{"key_":"index","val_":"0"},{"key_":"url","val_":"http://ion-kit.s3.us-west-2.amazonaws.com/images/pedestrian.jpg"}],"ports":[],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"4d84f5b5-8681-4d8c-a33b-c4eddaac3582","name":"image_processing_bayer_downscale_uint16","params":[{"key_":"input_width","val_":"3264"},{"key_":"input_height","val_":"2464"},{"key_":"downscale_factor","val_":"2"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"45e8e54e-f6c1-4773-a196-c4d064a84430","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"a4a521ea-c11d-4388-9c16-9ee9942a996f","name":"image_processing_normalize_raw_image","params":[{"key_":"bit_width","val_":"10"},{"key_":"bit_shift","val_":"6"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"4d84f5b5-8681-4d8c-a33b-c4eddaac3582","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"8e5a9cf7-03c2-4fe3-aedc-a7c9cb019270","name":"image_processing_bayer_offset","params":[],"ports":[{"dimensions_":0,"key_":"offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"a4a521ea-c11d-4388-9c16-9ee9942a996f","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"0949c5f1-20e9-4561-a9ad-f41fbfa5c358","name":"image_processing_lens_shading_correction_linear","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"shading_correction_slope_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"8e5a9cf7-03c2-4fe3-aedc-a7c9cb019270","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"2cdc6187-38b3-491d-a775-8e8351755f89","name":"image_processing_bayer_white_balance","params":[],"ports":[{"dimensions_":0,"key_":"gain_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"0949c5f1-20e9-4561-a9ad-f41fbfa5c358","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"0c37914d-72f7-41a0-b6e4-2922fe1643bc","name":"image_processing_bayer_demosaic_simple","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"2cdc6187-38b3-491d-a775-8e8351755f89","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"baf959c0-83dd-40bb-b5a9-6dfe7678710b","name":"image_processing_resize_bilinear_3d","params":[{"key_":"width","val_":"816"},{"key_":"height","val_":"616"},{"key_":"scale","val_":"0.675325"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"0c37914d-72f7-41a0-b6e4-2922fe1643bc","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"bc477a80-470d-4777-bca6-fea3e06bcf0b","name":"image_processing_gamma_correction_3d","params":[],"ports":[{"dimensions_":0,"key_":"gamma","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"baf959c0-83dd-40bb-b5a9-6dfe7678710b","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"ecb40056-ef5e-4e18-8b01-90b7d27cff5a","name":"image_processing_fit_image_to_center_3d_float","params":[{"key_":"input_width","val_":"551"},{"key_":"input_height","val_":"416"},{"key_":"output_width","val_":"416"},{"key_":"output_height","val_":"416"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"bc477a80-470d-4777-bca6-fea3e06bcf0b","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"421d163d-4a3b-4a6a-b768-5a8a44c8a29e","name":"image_processing_reorder_color_channel_3d_float","params":[],"ports":[{"dimensions_":0,"key_":"output","node_id_":"ecb40056-ef5e-4e18-8b01-90b7d27cff5a","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"f2397b04-dc1d-43fa-863c-f75152bcd3dd","name":"base_reorder_buffer_3d_float","params":[{"key_":"dim0","val_":"2"},{"key_":"dim1","val_":"0"},{"key_":"dim2","val_":"1"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"421d163d-4a3b-4a6a-b768-5a8a44c8a29e","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"85680ab8-90d4-423e-90c8-f8a524413621","name":"base_extend_dimension_3d_float","params":[{"key_":"new_dim","val_":"3"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"f2397b04-dc1d-43fa-863c-f75152bcd3dd","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"9b6f084c-152a-43b9-87af-85e044c8a90b","name":"image_io_imx219","params":[{"key_":"index","val_":"1"},{"key_":"url","val_":"http://ion-kit.s3.us-west-2.amazonaws.com/images/pedestrian.jpg"}],"ports":[],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"f4e1dcd0-95e3-4708-9f17-5d27c28c26c9","name":"image_processing_bayer_downscale_uint16","params":[{"key_":"input_width","val_":"3264"},{"key_":"input_height","val_":"2464"},{"key_":"downscale_factor","val_":"2"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"9b6f084c-152a-43b9-87af-85e044c8a90b","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"fb54bc78-5085-45d6-acf9-96aedd836c2e","name":"image_processing_normalize_raw_image","params":[{"key_":"bit_width","val_":"10"},{"key_":"bit_shift","val_":"6"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"f4e1dcd0-95e3-4708-9f17-5d27c28c26c9","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"831e8731-07bf-4aa9-a782-b3fb06a8677c","name":"image_processing_bayer_offset","params":[],"ports":[{"dimensions_":0,"key_":"offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"fb54bc78-5085-45d6-acf9-96aedd836c2e","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"de62a886-4464-4017-b4e0-2bdc607c681a","name":"image_processing_lens_shading_correction_linear","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"shading_correction_slope_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"831e8731-07bf-4aa9-a782-b3fb06a8677c","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"fc866d17-ba6f-439c-bf39-9183349eeee6","name":"image_processing_bayer_white_balance","params":[],"ports":[{"dimensions_":0,"key_":"gain_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"de62a886-4464-4017-b4e0-2bdc607c681a","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"30381bff-250e-4ede-a59c-3b089beedff7","name":"image_processing_bayer_demosaic_simple","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"fc866d17-ba6f-439c-bf39-9183349eeee6","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"ea8b69e9-62e3-4a8a-b4d3-3d7083e14dd2","name":"image_processing_resize_bilinear_3d","params":[{"key_":"width","val_":"816"},{"key_":"height","val_":"616"},{"key_":"scale","val_":"0.675325"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"30381bff-250e-4ede-a59c-3b089beedff7","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"38c4ad28-7150-411d-928c-dc20ba8e69ff","name":"image_processing_gamma_correction_3d","params":[],"ports":[{"dimensions_":0,"key_":"gamma","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"ea8b69e9-62e3-4a8a-b4d3-3d7083e14dd2","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"8e54dbe1-de37-49d3-8bd8-fe2a527512fe","name":"image_processing_fit_image_to_center_3d_float","params":[{"key_":"input_width","val_":"551"},{"key_":"input_height","val_":"416"},{"key_":"output_width","val_":"416"},{"key_":"output_height","val_":"416"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"38c4ad28-7150-411d-928c-dc20ba8e69ff","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"0d5ab5c3-e6fb-4537-ab83-2ad3b48583d4","name":"image_processing_reorder_color_channel_3d_float","params":[],"ports":[{"dimensions_":0,"key_":"output","node_id_":"8e54dbe1-de37-49d3-8bd8-fe2a527512fe","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"12a3604a-eba4-42fd-806a-58a26638c070","name":"base_reorder_buffer_3d_float","params":[{"key_":"dim0","val_":"2"},{"key_":"dim1","val_":"0"},{"key_":"dim2","val_":"1"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"0d5ab5c3-e6fb-4537-ab83-2ad3b48583d4","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"27da41b6-7b11-4c31-a50f-0503b66b7cc9","name":"base_extend_dimension_3d_float","params":[{"key_":"new_dim","val_":"3"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"12a3604a-eba4-42fd-806a-58a26638c070","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"169603c5-ec1e-465d-8369-971bd15a034d","name":"image_io_imx219","params":[{"key_":"index","val_":"2"},{"key_":"url","val_":"http://ion-kit.s3.us-west-2.amazonaws.com/images/pedestrian.jpg"}],"ports":[],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"38a54ec9-8b54-49d6-a02e-87f16c029f79","name":"image_processing_bayer_downscale_uint16","params":[{"key_":"input_width","val_":"3264"},{"key_":"input_height","val_":"2464"},{"key_":"downscale_factor","val_":"2"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"169603c5-ec1e-465d-8369-971bd15a034d","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"03a04682-663b-455f-96cf-26045402c238","name":"image_processing_normalize_raw_image","params":[{"key_":"bit_width","val_":"10"},{"key_":"bit_shift","val_":"6"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"38a54ec9-8b54-49d6-a02e-87f16c029f79","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"b848ae23-07be-424f-a5b5-5a38077246ac","name":"image_processing_bayer_offset","params":[],"ports":[{"dimensions_":0,"key_":"offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"03a04682-663b-455f-96cf-26045402c238","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"287a10a6-b5d6-4dc7-a786-5c338ba3405b","name":"image_processing_lens_shading_correction_linear","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"shading_correction_slope_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"b848ae23-07be-424f-a5b5-5a38077246ac","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"0255726c-9072-48fe-98f4-60db25d5663f","name":"image_processing_bayer_white_balance","params":[],"ports":[{"dimensions_":0,"key_":"gain_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"287a10a6-b5d6-4dc7-a786-5c338ba3405b","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"07b71554-d047-47f9-899f-59533abcd4b6","name":"image_processing_bayer_demosaic_simple","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"0255726c-9072-48fe-98f4-60db25d5663f","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"aa0b89ef-0d72-47bb-9d37-703432d67d95","name":"image_processing_resize_bilinear_3d","params":[{"key_":"width","val_":"816"},{"key_":"height","val_":"616"},{"key_":"scale","val_":"0.675325"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"07b71554-d047-47f9-899f-59533abcd4b6","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"a3dbc1a7-427b-4bba-9b0d-00eeae596ad7","name":"image_processing_gamma_correction_3d","params":[],"ports":[{"dimensions_":0,"key_":"gamma","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"aa0b89ef-0d72-47bb-9d37-703432d67d95","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"6cbd6c80-6407-4ea5-8e44-4f61903e85bf","name":"image_processing_fit_image_to_center_3d_float","params":[{"key_":"input_width","val_":"551"},{"key_":"input_height","val_":"416"},{"key_":"output_width","val_":"416"},{"key_":"output_height","val_":"416"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"a3dbc1a7-427b-4bba-9b0d-00eeae596ad7","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"683c978c-e009-4602-9d35-6ca527399204","name":"image_processing_reorder_color_channel_3d_float","params":[],"ports":[{"dimensions_":0,"key_":"output","node_id_":"6cbd6c80-6407-4ea5-8e44-4f61903e85bf","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"21eee05c-695e-4f07-b98b-2721ea9409fb","name":"base_reorder_buffer_3d_float","params":[{"key_":"dim0","val_":"2"},{"key_":"dim1","val_":"0"},{"key_":"dim2","val_":"1"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"683c978c-e009-4602-9d35-6ca527399204","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"27c2599d-0c87-475c-a13f-cacf755ef5bb","name":"base_extend_dimension_3d_float","params":[{"key_":"new_dim","val_":"3"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"21eee05c-695e-4f07-b98b-2721ea9409fb","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"81600864-b92a-499a-8352-d25f37379693","name":"image_io_imx219","params":[{"key_":"index","val_":"3"},{"key_":"url","val_":"http://ion-kit.s3.us-west-2.amazonaws.com/images/pedestrian.jpg"}],"ports":[],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"ec422fab-aef4-4faf-b1af-d2b381349349","name":"image_processing_bayer_downscale_uint16","params":[{"key_":"input_width","val_":"3264"},{"key_":"input_height","val_":"2464"},{"key_":"downscale_factor","val_":"2"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"81600864-b92a-499a-8352-d25f37379693","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"a18db56a-1c77-42d5-915f-c1b1cef9cafd","name":"image_processing_normalize_raw_image","params":[{"key_":"bit_width","val_":"10"},{"key_":"bit_shift","val_":"6"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"ec422fab-aef4-4faf-b1af-d2b381349349","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"2cdeec19-4258-46a6-ad96-ec2156182c5f","name":"image_processing_bayer_offset","params":[],"ports":[{"dimensions_":0,"key_":"offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"a18db56a-1c77-42d5-915f-c1b1cef9cafd","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"76f749de-4f56-4fbe-8233-cb6e0fb3bf61","name":"image_processing_lens_shading_correction_linear","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"shading_correction_slope_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"2cdeec19-4258-46a6-ad96-ec2156182c5f","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"e152f687-b96d-4c70-892a-79b2da0877fb","name":"image_processing_bayer_white_balance","params":[],"ports":[{"dimensions_":0,"key_":"gain_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"76f749de-4f56-4fbe-8233-cb6e0fb3bf61","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"704a5e2f-64c2-45e2-976f-73fd46da8f03","name":"image_processing_bayer_demosaic_simple","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"e152f687-b96d-4c70-892a-79b2da0877fb","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"547cecfa-4650-441d-9197-e036569818e4","name":"image_processing_resize_bilinear_3d","params":[{"key_":"width","val_":"816"},{"key_":"height","val_":"616"},{"key_":"scale","val_":"0.675325"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"704a5e2f-64c2-45e2-976f-73fd46da8f03","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"951e7112-1825-4570-bbf1-9e0bd45bd7b1","name":"image_processing_gamma_correction_3d","params":[],"ports":[{"dimensions_":0,"key_":"gamma","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"547cecfa-4650-441d-9197-e036569818e4","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"5c5a130b-962f-4d67-b2eb-3c350fe32b5f","name":"image_processing_fit_image_to_center_3d_float","params":[{"key_":"input_width","val_":"551"},{"key_":"input_height","val_":"416"},{"key_":"output_width","val_":"416"},{"key_":"output_height","val_":"416"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"951e7112-1825-4570-bbf1-9e0bd45bd7b1","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"2bf497c9-0e42-4fda-a921-8c288309d14f","name":"image_processing_reorder_color_channel_3d_float","params":[],"ports":[{"dimensions_":0,"key_":"output","node_id_":"5c5a130b-962f-4d67-b2eb-3c350fe32b5f","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"5a4b0e14-3433-45aa-82ae-27978a4ab5db","name":"base_reorder_buffer_3d_float","params":[{"key_":"dim0","val_":"2"},{"key_":"dim1","val_":"0"},{"key_":"dim2","val_":"1"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"2bf497c9-0e42-4fda-a921-8c288309d14f","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"aa4cbf6f-3b35-4252-b750-08df5548d1bc","name":"base_extend_dimension_3d_float","params":[{"key_":"new_dim","val_":"3"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"5a4b0e14-3433-45aa-82ae-27978a4ab5db","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"0133307e-4ce2-4dd2-9f0d-1f0154008ef9","name":"image_io_imx219","params":[{"key_":"index","val_":"4"},{"key_":"url","val_":"http://ion-kit.s3.us-west-2.amazonaws.com/images/pedestrian.jpg"}],"ports":[],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"f5625498-32f8-4c83-b59b-ce5e9024e890","name":"image_processing_bayer_downscale_uint16","params":[{"key_":"input_width","val_":"3264"},{"key_":"input_height","val_":"2464"},{"key_":"downscale_factor","val_":"2"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"0133307e-4ce2-4dd2-9f0d-1f0154008ef9","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"992c3b4e-9d7c-4ec6-915a-881bcc4cde6e","name":"image_processing_normalize_raw_image","params":[{"key_":"bit_width","val_":"10"},{"key_":"bit_shift","val_":"6"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"f5625498-32f8-4c83-b59b-ce5e9024e890","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"1dddae9d-2f0e-4fb0-b2f0-ae12831af25b","name":"image_processing_bayer_offset","params":[],"ports":[{"dimensions_":0,"key_":"offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"992c3b4e-9d7c-4ec6-915a-881bcc4cde6e","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"cbd2f319-a4a5-4ebc-a37e-78d5b8f170be","name":"image_processing_lens_shading_correction_linear","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"shading_correction_slope_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"1dddae9d-2f0e-4fb0-b2f0-ae12831af25b","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"e849bfe5-d044-4259-924c-094f3fe6bbdd","name":"image_processing_bayer_white_balance","params":[],"ports":[{"dimensions_":0,"key_":"gain_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"cbd2f319-a4a5-4ebc-a37e-78d5b8f170be","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"c5166dd4-484f-4a42-b314-f5fdcca3020f","name":"image_processing_bayer_demosaic_simple","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"e849bfe5-d044-4259-924c-094f3fe6bbdd","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"79d02637-f784-44cc-b51a-a88ccba696ee","name":"image_processing_resize_bilinear_3d","params":[{"key_":"width","val_":"816"},{"key_":"height","val_":"616"},{"key_":"scale","val_":"0.675325"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"c5166dd4-484f-4a42-b314-f5fdcca3020f","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"f1d5a826-2eae-460e-939f-b0aa3cefe4e6","name":"image_processing_gamma_correction_3d","params":[],"ports":[{"dimensions_":0,"key_":"gamma","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"79d02637-f784-44cc-b51a-a88ccba696ee","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"a19c9d5b-d7d1-4d72-9385-112db53862e7","name":"image_processing_fit_image_to_center_3d_float","params":[{"key_":"input_width","val_":"551"},{"key_":"input_height","val_":"416"},{"key_":"output_width","val_":"416"},{"key_":"output_height","val_":"416"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"f1d5a826-2eae-460e-939f-b0aa3cefe4e6","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"bbbf59c5-594e-43cf-b56b-b487169334b6","name":"image_processing_reorder_color_channel_3d_float","params":[],"ports":[{"dimensions_":0,"key_":"output","node_id_":"a19c9d5b-d7d1-4d72-9385-112db53862e7","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"a03e6319-1195-465f-bfa9-3c4903a7ab04","name":"base_reorder_buffer_3d_float","params":[{"key_":"dim0","val_":"2"},{"key_":"dim1","val_":"0"},{"key_":"dim2","val_":"1"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"bbbf59c5-594e-43cf-b56b-b487169334b6","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"74b06c2e-1444-45f7-946a-7ca9c46d1ccf","name":"base_extend_dimension_3d_float","params":[{"key_":"new_dim","val_":"3"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"a03e6319-1195-465f-bfa9-3c4903a7ab04","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"88d385a3-bb2c-4ee9-8b5e-0b7fed1f1eec","name":"image_io_imx219","params":[{"key_":"index","val_":"5"},{"key_":"url","val_":"http://ion-kit.s3.us-west-2.amazonaws.com/images/pedestrian.jpg"}],"ports":[],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"898e1443-6033-4c5a-9547-ac465fad65f9","name":"image_processing_bayer_downscale_uint16","params":[{"key_":"input_width","val_":"3264"},{"key_":"input_height","val_":"2464"},{"key_":"downscale_factor","val_":"2"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"88d385a3-bb2c-4ee9-8b5e-0b7fed1f1eec","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"17b555f8-b3b2-48fb-8b73-f1c770df4ab1","name":"image_processing_normalize_raw_image","params":[{"key_":"bit_width","val_":"10"},{"key_":"bit_shift","val_":"6"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"898e1443-6033-4c5a-9547-ac465fad65f9","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"85a9a5ef-4434-4905-b6b0-1dc10ba65be7","name":"image_processing_bayer_offset","params":[],"ports":[{"dimensions_":0,"key_":"offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"17b555f8-b3b2-48fb-8b73-f1c770df4ab1","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"b2f02255-2c93-49ff-b3df-b05f651acd5d","name":"image_processing_lens_shading_correction_linear","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"shading_correction_slope_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_slope_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"shading_correction_offset_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"85a9a5ef-4434-4905-b6b0-1dc10ba65be7","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"147dd3b7-7106-447b-add6-31521cde5a3b","name":"image_processing_bayer_white_balance","params":[],"ports":[{"dimensions_":0,"key_":"gain_r","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_g","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"gain_b","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"b2f02255-2c93-49ff-b3df-b05f651acd5d","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"40081848-a1f8-4eb2-9f4d-968423dffe1d","name":"image_processing_bayer_demosaic_simple","params":[{"key_":"width","val_":"1632"},{"key_":"height","val_":"1232"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"147dd3b7-7106-447b-add6-31521cde5a3b","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"12892599-3ccb-4ea1-a983-0c91ec4ebeb0","name":"image_processing_resize_bilinear_3d","params":[{"key_":"width","val_":"816"},{"key_":"height","val_":"616"},{"key_":"scale","val_":"0.675325"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"40081848-a1f8-4eb2-9f4d-968423dffe1d","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"48dc330b-03d9-4218-b7b9-c43273e5ac77","name":"image_processing_gamma_correction_3d","params":[],"ports":[{"dimensions_":0,"key_":"gamma","node_id_":"","type_":{"bits":32,"code":2,"lanes":1}},{"dimensions_":0,"key_":"output","node_id_":"12892599-3ccb-4ea1-a983-0c91ec4ebeb0","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"6d9c0949-1002-4b61-bf89-cbce120459bb","name":"image_processing_fit_image_to_center_3d_float","params":[{"key_":"input_width","val_":"551"},{"key_":"input_height","val_":"416"},{"key_":"output_width","val_":"416"},{"key_":"output_height","val_":"416"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"48dc330b-03d9-4218-b7b9-c43273e5ac77","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"d747c7a2-b65c-4cfc-97ba-c083cbe9a694","name":"image_processing_reorder_color_channel_3d_float","params":[],"ports":[{"dimensions_":0,"key_":"output","node_id_":"6d9c0949-1002-4b61-bf89-cbce120459bb","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"cab19bfa-82ff-46be-b941-1f35421bca79","name":"base_reorder_buffer_3d_float","params":[{"key_":"dim0","val_":"2"},{"key_":"dim1","val_":"0"},{"key_":"dim2","val_":"1"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"d747c7a2-b65c-4cfc-97ba-c083cbe9a694","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"38e35fd6-dc63-4726-bfe4-a64edca0a7a6","name":"base_extend_dimension_3d_float","params":[{"key_":"new_dim","val_":"3"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"cab19bfa-82ff-46be-b941-1f35421bca79","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"1b71a8d5-b5b2-489d-a790-ca54b30d553f","name":"base_concat_buffer_4d_float","params":[{"key_":"dim","val_":"3"},{"key_":"input0_extent","val_":"1"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"85680ab8-90d4-423e-90c8-f8a524413621","type_":{"bits":0,"code":3,"lanes":0}},{"dimensions_":0,"key_":"output","node_id_":"27da41b6-7b11-4c31-a50f-0503b66b7cc9","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"10bd31ac-7884-4763-99e1-d69e494f736a","name":"base_concat_buffer_4d_float","params":[{"key_":"dim","val_":"3"},{"key_":"input0_extent","val_":"2"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"1b71a8d5-b5b2-489d-a790-ca54b30d553f","type_":{"bits":0,"code":3,"lanes":0}},{"dimensions_":0,"key_":"output","node_id_":"27c2599d-0c87-475c-a13f-cacf755ef5bb","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"e548d112-0843-46f5-a51a-0d44c2d79d64","name":"base_concat_buffer_4d_float","params":[{"key_":"dim","val_":"3"},{"key_":"input0_extent","val_":"3"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"10bd31ac-7884-4763-99e1-d69e494f736a","type_":{"bits":0,"code":3,"lanes":0}},{"dimensions_":0,"key_":"output","node_id_":"aa4cbf6f-3b35-4252-b750-08df5548d1bc","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"73b4ee3c-4a24-458f-a49e-de803349f826","name":"base_concat_buffer_4d_float","params":[{"key_":"dim","val_":"3"},{"key_":"input0_extent","val_":"4"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"e548d112-0843-46f5-a51a-0d44c2d79d64","type_":{"bits":0,"code":3,"lanes":0}},{"dimensions_":0,"key_":"output","node_id_":"74b06c2e-1444-45f7-946a-7ca9c46d1ccf","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"cacd780c-a1dd-43fb-b9bf-c38814c4c91b","name":"base_concat_buffer_4d_float","params":[{"key_":"dim","val_":"3"},{"key_":"input0_extent","val_":"5"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"73b4ee3c-4a24-458f-a49e-de803349f826","type_":{"bits":0,"code":3,"lanes":0}},{"dimensions_":0,"key_":"output","node_id_":"38e35fd6-dc63-4726-bfe4-a64edca0a7a6","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"10f8a75f-c20a-499a-bfd4-70cec095a98c","name":"dnn_object_detection_array","params":[],"ports":[{"dimensions_":0,"key_":"output","node_id_":"cacd780c-a1dd-43fb-b9bf-c38814c4c91b","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"4d8fa9bf-2be2-487d-93dc-90e6d1c569a2","name":"base_extract_buffer_4d_float","params":[{"key_":"dim","val_":"3"},{"key_":"index","val_":"0"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"10f8a75f-c20a-499a-bfd4-70cec095a98c","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"bd181b36-c377-4e45-a195-98191b011fa7","name":"base_extract_buffer_4d_float","params":[{"key_":"dim","val_":"3"},{"key_":"index","val_":"1"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"10f8a75f-c20a-499a-bfd4-70cec095a98c","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"d7db2cb0-53ad-4138-b124-24f85982444f","name":"base_extract_buffer_4d_float","params":[{"key_":"dim","val_":"3"},{"key_":"index","val_":"2"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"10f8a75f-c20a-499a-bfd4-70cec095a98c","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"4836b891-086a-406c-a182-3db0e306c6b6","name":"base_extract_buffer_4d_float","params":[{"key_":"dim","val_":"3"},{"key_":"index","val_":"3"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"10f8a75f-c20a-499a-bfd4-70cec095a98c","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"1f5c4689-0861-45ae-ad7a-44ea37032d67","name":"base_extract_buffer_4d_float","params":[{"key_":"dim","val_":"3"},{"key_":"index","val_":"4"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"10f8a75f-c20a-499a-bfd4-70cec095a98c","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"dff76dac-1edf-4ed0-8ec5-3fbb9932461f","name":"base_extract_buffer_4d_float","params":[{"key_":"dim","val_":"3"},{"key_":"index","val_":"5"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"10f8a75f-c20a-499a-bfd4-70cec095a98c","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"66be5b19-16ad-4ef6-9c8c-9a156a654854","name":"image_processing_tile_image_horizontal_3d_float","params":[{"key_":"x_dim","val_":"1"},{"key_":"y_dim","val_":"2"},{"key_":"input0_width","val_":"416"},{"key_":"input0_height","val_":"416"},{"key_":"input1_width","val_":"416"},{"key_":"input1_height","val_":"416"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"4d8fa9bf-2be2-487d-93dc-90e6d1c569a2","type_":{"bits":0,"code":3,"lanes":0}},{"dimensions_":0,"key_":"output","node_id_":"bd181b36-c377-4e45-a195-98191b011fa7","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"6333e7f5-2af8-4f97-ad12-55d67d4e7990","name":"image_processing_tile_image_horizontal_3d_float","params":[{"key_":"x_dim","val_":"1"},{"key_":"y_dim","val_":"2"},{"key_":"input0_width","val_":"832"},{"key_":"input0_height","val_":"416"},{"key_":"input1_width","val_":"416"},{"key_":"input1_height","val_":"416"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"66be5b19-16ad-4ef6-9c8c-9a156a654854","type_":{"bits":0,"code":3,"lanes":0}},{"dimensions_":0,"key_":"output","node_id_":"d7db2cb0-53ad-4138-b124-24f85982444f","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"89bb4d07-44d5-4ac7-9fb4-fe214c129524","name":"image_processing_tile_image_horizontal_3d_float","params":[{"key_":"x_dim","val_":"1"},{"key_":"y_dim","val_":"2"},{"key_":"input0_width","val_":"416"},{"key_":"input0_height","val_":"416"},{"key_":"input1_width","val_":"416"},{"key_":"input1_height","val_":"416"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"4836b891-086a-406c-a182-3db0e306c6b6","type_":{"bits":0,"code":3,"lanes":0}},{"dimensions_":0,"key_":"output","node_id_":"1f5c4689-0861-45ae-ad7a-44ea37032d67","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"203fb938-51c8-4a3e-b2b1-959794ca8acf","name":"image_processing_tile_image_horizontal_3d_float","params":[{"key_":"x_dim","val_":"1"},{"key_":"y_dim","val_":"2"},{"key_":"input0_width","val_":"832"},{"key_":"input0_height","val_":"416"},{"key_":"input1_width","val_":"416"},{"key_":"input1_height","val_":"416"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"89bb4d07-44d5-4ac7-9fb4-fe214c129524","type_":{"bits":0,"code":3,"lanes":0}},{"dimensions_":0,"key_":"output","node_id_":"dff76dac-1edf-4ed0-8ec5-3fbb9932461f","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"7fa4fbf5-9a3c-4bed-af69-970505bab97d","name":"image_processing_tile_image_vertical_3d_float","params":[{"key_":"x_dim","val_":"1"},{"key_":"y_dim","val_":"2"},{"key_":"input0_width","val_":"1248"},{"key_":"input0_height","val_":"416"},{"key_":"input1_width","val_":"1248"},{"key_":"input1_height","val_":"416"}],"ports":[{"dimensions_":0,"key_":"output","node_id_":"6333e7f5-2af8-4f97-ad12-55d67d4e7990","type_":{"bits":0,"code":3,"lanes":0}},{"dimensions_":0,"key_":"output","node_id_":"203fb938-51c8-4a3e-b2b1-959794ca8acf","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"b9876919-7bfa-46dc-89f0-e5e77cdb08a4","name":"base_denormalize_3d_uint8","params":[],"ports":[{"dimensions_":0,"key_":"output","node_id_":"7fa4fbf5-9a3c-4bed-af69-970505bab97d","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"85049eb5-f05b-4784-82c1-8fcfc62d88bb","name":"image_io_d435","params":[],"ports":[],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"},{"id":"addc321d-7c3e-4fe1-9450-cfc5feeeb850","name":"sgm_sgm","params":[{"key_":"disp","val_":"16"},{"key_":"width","val_":"1280"},{"key_":"height","val_":"720"}],"ports":[{"dimensions_":0,"key_":"output_l","node_id_":"85049eb5-f05b-4784-82c1-8fcfc62d88bb","type_":{"bits":0,"code":3,"lanes":0}},{"dimensions_":0,"key_":"output_r","node_id_":"85049eb5-f05b-4784-82c1-8fcfc62d88bb","type_":{"bits":0,"code":3,"lanes":0}}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"}],"target":"x86-64-linux-avx-avx2-avx512-avx512_skylake-f16c-fma-sse41"} \ No newline at end of file diff --git a/src/bb/image-io/rt_common.h b/src/bb/image-io/rt_common.h index 3c8e0d61..f30fba3a 100644 --- a/src/bb/image-io/rt_common.h +++ b/src/bb/image-io/rt_common.h @@ -176,6 +176,7 @@ 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 diff --git a/test/port-access.cc b/test/port-access.cc index 6565c0fb..f5e1e1e6 100644 --- a/test/port-access.cc +++ b/test/port-access.cc @@ -27,8 +27,8 @@ void display_image_float(Halide::Buffer buffer, std::string filename) { 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); } @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) { Param{"urls", "http://optipng.sourceforge.net/pngtech/img/lena.png;https://upload.wikimedia.org/wikipedia/commons/0/05/Cat.png"} //input urls split by ';' ); - n = b.add("base_normalize_3d_uint8")(n["output"][0]); // access only port[1] + 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)}, From 402fa71dcef6b3f515d29f4de820b68e2128eff4 Mon Sep 17 00:00:00 2001 From: xinyuli1204 Date: Thu, 30 Nov 2023 11:06:39 -0800 Subject: [PATCH 03/11] fix cmake --- CMakeLists.txt | 19 +------------------ src/bb/base/rt.h | 22 ++++++---------------- src/bb/image-io/rt_common.h | 32 +++++++------------------------- src/builder.cc | 17 +++-------------- test/port-access.cc | 5 ++--- 5 files changed, 19 insertions(+), 76 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 616e314c..99cf4f05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,10 +37,6 @@ if (WITH_CUDA) find_package(CUDA REQUIRED) endif() - - - - # # Version # @@ -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 # @@ -208,5 +192,4 @@ else () set(CPACK_GENERATOR "ZIP") endif () set(CPACK_PACKAGE_VERSION ${ION_KIT_VERSION}) -include(CPack) - +include(CPack) \ No newline at end of file diff --git a/src/bb/base/rt.h b/src/bb/base/rt.h index 3dc8bf50..a057f3b3 100644 --- a/src/bb/base/rt.h +++ b/src/bb/base/rt.h @@ -41,20 +41,14 @@ namespace bb { namespace base { std::tuple 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("", ""); } - 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(host_name, path_name); } @@ -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) { diff --git a/src/bb/image-io/rt_common.h b/src/bb/image-io/rt_common.h index f30fba3a..664a61e4 100644 --- a/src/bb/image-io/rt_common.h +++ b/src/bb/image-io/rt_common.h @@ -140,21 +140,14 @@ namespace ion { }; std::tuple 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("", ""); } - - 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(host_name, path_name); } @@ -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()); @@ -220,13 +208,7 @@ namespace ion { std::ifstream ifs(url, std::ios::binary); ifs.read(reinterpret_cast(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) { diff --git a/src/builder.cc b/src/builder.cc index d55d297e..6a3d2e15 100644 --- a/src/builder.cc +++ b/src/builder.cc @@ -315,6 +315,9 @@ Halide::Pipeline Builder::build(const ion::PortMap& pm, std::vectorbuild_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])); } @@ -348,20 +351,6 @@ Halide::Pipeline Builder::build(const ion::PortMap& pm, std::vectorpush_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; ipush_back(kv.second[i]); -// } -// } } else { auto f = bbs[node_id]->get_outputs(port_key).front(); if (1 != kv.second.size()) { diff --git a/test/port-access.cc b/test/port-access.cc index f5e1e1e6..18b979f4 100644 --- a/test/port-access.cc +++ b/test/port-access.cc @@ -26,9 +26,8 @@ void display_image_float(Halide::Buffer 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); } From 8976f62802bf4a4c2fdb47f7c7468eaffd62adf3 Mon Sep 17 00:00:00 2001 From: xinyuli1204 Date: Thu, 30 Nov 2023 11:50:35 -0800 Subject: [PATCH 04/11] fix port-access test --- test/port-access.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/port-access.cc b/test/port-access.cc index 18b979f4..46d108bb 100644 --- a/test/port-access.cc +++ b/test/port-access.cc @@ -26,8 +26,9 @@ void display_image_float(Halide::Buffer buffer, std::string filename) { cv::Mat img_float(height, width, CV_32F, buffer.data()); img_float.convertTo(img_out, CV_8U, 255); } +#ifdef DISPLAY cv::imshow( "Display window: " + filename, img_out); -// cv::imwrite("./saved.png", img_out); +#endif } @@ -52,7 +53,7 @@ int main(int argc, char *argv[]) { wparam, hparam, Param{"num_devices", "2"}, - Param{"urls", "http://optipng.sourceforge.net/pngtech/img/lena.png;https://upload.wikimedia.org/wikipedia/commons/0/05/Cat.png"} + Param{"urls", "http://optipng.sourceforge.net/pngtech/img/lena.png;http://upload.wikimedia.org/wikipedia/commons/0/05/Cat.png"} //input urls split by ';' ); n = b.add("base_normalize_3d_uint8")(n["output"][1]); // access only port[1] From 778d61b27d82866290c82f74e4476704facac81e Mon Sep 17 00:00:00 2001 From: xinyuli1204 Date: Thu, 30 Nov 2023 12:09:21 -0800 Subject: [PATCH 05/11] fix arrayoutput --- include/ion/port_map.h | 267 ++++++++++++++++++++--------------------- 1 file changed, 128 insertions(+), 139 deletions(-) diff --git a/include/ion/port_map.h b/include/ion/port_map.h index 27259ee0..43912e49 100644 --- a/include/ion/port_map.h +++ b/include/ion/port_map.h @@ -12,22 +12,22 @@ namespace std { -template<> -struct hash> + template<> + struct hash> { std::size_t operator()(const tuple& k) const noexcept - { - return std::hash{}(std::get<0>(k)) ^ std::hash{}(std::get<1>(k)); - } +{ + return std::hash{}(std::get<0>(k)) ^ std::hash{}(std::get<1>(k)); +} }; template<> struct equal_to> { - bool operator()(const tuple& v0, const tuple& v1) const - { - return (std::get<0>(v0) == std::get<0>(v1) && std::get<1>(v0) == std::get<1>(v1)); - } +bool operator()(const tuple& v0, const tuple& v1) const +{ + return (std::get<0>(v0) == std::get<0>(v1) && std::get<1>(v0) == std::get<1>(v1)); +} }; } // std @@ -37,146 +37,135 @@ namespace ion { /** * PortMap is used to assign actual value to the port input. */ -class PortMap { - -public: - - template - void set(const Halide::Param& p, T v) { - param_expr_[p.name()] = p; - param_map_.set(p, v); - } - - template - void set(const Halide::ImageParam& p, Halide::Buffer &buf) { - param_func_[p.name()] = p; - param_map_.set(p, buf); - } - - /** - * Set the scalar value against to the port. - * Template type T is allowed to be one of the following. - * - bool - * - uint8_t - * - uint16_t - * - uint32_t - * - uint64_t - * - int8_t - * - int16_t - * - int32_t - * - int64_t - * - float - * - double - * @arg p: The port object which value is assigned. - * @arg v: Actual value to be mapped to the port. - */ - template - void set(Port p, T v) { - param_expr_[p.key()] = p.expr(); - p.set_to_param_map(param_map_, v); - } - - /** - * Set the vector value against to the port. - * Following type value is allowed to specified: - * - bool - * - uint8_t - * - uint16_t - * - uint32_t - * - uint64_t - * - int8_t - * - int16_t - * - int32_t - * - int64_t - * - float - * - double - * @arg p: The port object which value is assigned. - * @arg buf: Actual value to be mapped to the port. - * Buffer dimension should be matched with port's one. - */ - template - void set(Port p, Halide::Buffer &buf) { - if (p.bound()) { - // This is just an output. - output_buffer_[std::make_tuple(p.node_id(), p.key())] = { buf }; - } else { - param_func_[p.key()] = p.func(); - p.set_to_param_map(param_map_, buf); + class PortMap { + + public: + + template + void set(const Halide::Param& p, T v) { + param_expr_[p.name()] = p; + param_map_.set(p, v); + } + + template + void set(const Halide::ImageParam& p, Halide::Buffer &buf) { + param_func_[p.name()] = p; + param_map_.set(p, buf); + } + + /** + * Set the scalar value against to the port. + * Template type T is allowed to be one of the following. + * - bool + * - uint8_t + * - uint16_t + * - uint32_t + * - uint64_t + * - int8_t + * - int16_t + * - int32_t + * - int64_t + * - float + * - double + * @arg p: The port object which value is assigned. + * @arg v: Actual value to be mapped to the port. + */ + template + void set(Port p, T v) { + param_expr_[p.key()] = p.expr(); + p.set_to_param_map(param_map_, v); } - } - - /** - * Set the vector of the vector values against to the port. - * Following type value is allowed to specified: - * - bool - * - uint8_t - * - uint16_t - * - uint32_t - * - uint64_t - * - int8_t - * - int16_t - * - int32_t - * - int64_t - * - float - * - double - * @arg p: The port object which value is assigned. - * @arg bufs: Actual value to be mapped to the port. - * Buffer dimension should be matched with port's one. - */ - template - void set(Port p, const std::vector> &bufs) { - if (p.bound()) { - // This is just an output. -// if (p.index()!=-1){ -// for (size_t i=0; i=buf.size()){ -// throw std::invalid_argument( -// "Port index is out of range"); -// } - - output_buffer_[std::make_tuple(p.node_id(), p.key())].push_back(bufs[p.index()]); - -// } - - - } else { - throw std::invalid_argument( - "Unbounded port (" + p.key() + ") corresponding to an array of Inputs is not supported"); + + /** + * Set the vector value against to the port. + * Following type value is allowed to specified: + * - bool + * - uint8_t + * - uint16_t + * - uint32_t + * - uint64_t + * - int8_t + * - int16_t + * - int32_t + * - int64_t + * - float + * - double + * @arg p: The port object which value is assigned. + * @arg buf: Actual value to be mapped to the port. + * Buffer dimension should be matched with port's one. + */ + template + void set(Port p, Halide::Buffer &buf) { + if (p.bound()) { + // This is just an output. + output_buffer_[std::make_tuple(p.node_id(), p.key())] = { buf }; + } else { + param_func_[p.key()] = p.func(); + p.set_to_param_map(param_map_, buf); + } } - } - bool mapped(const std::string& k) const { - return param_expr_.count(k) != 0 || param_func_.count(k) != 0; - } + /** + * Set the vector of the vector values against to the port. + * Following type value is allowed to specified: + * - bool + * - uint8_t + * - uint16_t + * - uint32_t + * - uint64_t + * - int8_t + * - int16_t + * - int32_t + * - int64_t + * - float + * - double + * @arg p: The port object which value is assigned. + * @arg bufs: Actual value to be mapped to the port. + * Buffer dimension should be matched with port's one. + */ + template + void set(Port p, const std::vector> &bufs) { + if (p.bound()) { + // This is just an output. + + for (size_t i=0; i, std::vector>> get_output_buffer() const { - return output_buffer_; - } + Halide::Func get_param_func(const std::string& k) const { + return param_func_.at(k); + } - Halide::ParamMap get_param_map() const { - return param_map_; - } + std::unordered_map, std::vector>> get_output_buffer() const { + return output_buffer_; + } + + Halide::ParamMap get_param_map() const { + return param_map_; + } - private: + private: - std::unordered_map param_expr_; - std::unordered_map param_func_; - std::unordered_map, std::vector>> output_buffer_; - Halide::ParamMap param_map_; -}; + std::unordered_map param_expr_; + std::unordered_map param_func_; + std::unordered_map, std::vector>> output_buffer_; + Halide::ParamMap param_map_; + }; } // namespace ion -#endif // ION_PORT_MAP_H +#endif // ION_PORT_MAP_H \ No newline at end of file From 9aafe11f8afde043b348b938ff01dd7a13db2f1b Mon Sep 17 00:00:00 2001 From: xinyuli1204 Date: Thu, 30 Nov 2023 12:30:09 -0800 Subject: [PATCH 06/11] fix --- CMakeLists.txt | 2 +- include/ion/port_map.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 99cf4f05..bb50ad3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -192,4 +192,4 @@ else () set(CPACK_GENERATOR "ZIP") endif () set(CPACK_PACKAGE_VERSION ${ION_KIT_VERSION}) -include(CPack) \ No newline at end of file +include(CPack) diff --git a/include/ion/port_map.h b/include/ion/port_map.h index 43912e49..523b100e 100644 --- a/include/ion/port_map.h +++ b/include/ion/port_map.h @@ -168,4 +168,4 @@ namespace ion { } // namespace ion -#endif // ION_PORT_MAP_H \ No newline at end of file +#endif // ION_PORT_MAP_H From c3c293a07cdbba0b6e1d589830c38c6c174ee038 Mon Sep 17 00:00:00 2001 From: xinyuli1204 Date: Thu, 30 Nov 2023 12:40:32 -0800 Subject: [PATCH 07/11] fix format --- CMakeLists.txt | 50 ++++---- example/gender_count.cc | 17 ++- include/ion/port_map.h | 254 ++++++++++++++++++++-------------------- 3 files changed, 166 insertions(+), 155 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb50ad3c..08a85ea4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,9 +6,9 @@ cmake_minimum_required(VERSION 3.6) # Options # if (UNIX) - set(DEFAULT_TARGET_BB "base;dnn;image-io;image-processing;opencv;sgm") + set(DEFAULT_TARGET_BB "base;dnn;image-io;image-processing;opencv;sgm") else() - set(DEFAULT_TARGET_BB "base;image-io;image-processing;opencv;sgm") + set(DEFAULT_TARGET_BB "base;image-io;image-processing;opencv;sgm") endif() set(ION_TARGET_BB ${DEFAULT_TARGET_BB} CACHE STRING "A List of building blocks to build (This overrides ION_BUILD_ALL_BB)") option(ION_BUILD_DOC "Build documents." OFF) @@ -41,8 +41,8 @@ endif() # Version # execute_process(COMMAND git describe --tags - OUTPUT_VARIABLE GIT_DESCRIBE_RESULT - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + OUTPUT_VARIABLE GIT_DESCRIBE_RESULT + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) message(STATUS "Version: ${GIT_DESCRIBE_RESULT}") string(STRIP "${GIT_DESCRIBE_RESULT}" ION_KIT_VERSION_S) add_definitions("-DION_KIT_VERSION=\"${ION_KIT_VERSION_S}\"") @@ -68,9 +68,9 @@ file(GLOB ION_CORE_SRC LIST_DIRECTORIES false ${PROJECT_SOURCE_DIR}/src/*) add_library(ion-core SHARED ${ION_CORE_SRC}) target_include_directories(ion-core PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/src) if (UNIX) - target_link_libraries(ion-core PUBLIC Halide::Halide Halide::Runtime dl pthread z) + target_link_libraries(ion-core PUBLIC Halide::Halide Halide::Runtime dl pthread z) else() - target_link_libraries(ion-core PUBLIC Halide::Halide Halide::Runtime) + target_link_libraries(ion-core PUBLIC Halide::Halide Halide::Runtime) endif() # @@ -105,19 +105,19 @@ if (ION_BUILD_DOC) list(APPEND PUBLIC_HEADERS ${FILES}) set(DOXYGEN_INDEX_FILE ${CMAKE_BINARY_DIR}/xml/index.xml) add_custom_command(OUTPUT ${DOXYGEN_INDEX_FILE} - COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_SOURCE_DIR}/doc/Doxyfile - DEPENDS ${PUBLIC_HEADERS} - MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/doc/Doxyfile - COMMENT "Generating docs") + COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_SOURCE_DIR}/doc/Doxyfile + DEPENDS ${PUBLIC_HEADERS} + MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/doc/Doxyfile + COMMENT "Generating docs") add_custom_target(Doxygen ALL DEPENDS ${DOXYGEN_INDEX_FILE}) set(SPHINX_INDEX_FILE ${CMAKE_BINARY_DIR}/doc/index.html) add_custom_command(OUTPUT ${SPHINX_INDEX_FILE} - COMMAND ${SPHINX_EXECUTABLE} -b html - -Dbreathe_projects.ion-core=${CMAKE_BINARY_DIR}/xml - ${CMAKE_SOURCE_DIR}/doc ${CMAKE_BINARY_DIR}/doc - DEPENDS ${DOXYGEN_INDEX_FILE} - MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/doc/index.rst) + COMMAND ${SPHINX_EXECUTABLE} -b html + -Dbreathe_projects.ion-core=${CMAKE_BINARY_DIR}/xml + ${CMAKE_SOURCE_DIR}/doc ${CMAKE_BINARY_DIR}/doc + DEPENDS ${DOXYGEN_INDEX_FILE} + MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/doc/index.rst) add_custom_target(Sphinx ALL DEPENDS ${SPHINX_INDEX_FILE}) install(DIRECTORY ${CMAKE_BINARY_DIR}/doc DESTINATION .) @@ -141,14 +141,14 @@ endif() install(DIRECTORY include DESTINATION .) install(FILES - ${CMAKE_BINARY_DIR}/VERSION - DESTINATION .) + ${CMAKE_BINARY_DIR}/VERSION + DESTINATION .) install(FILES - ${CMAKE_SOURCE_DIR}/LICENSE - DESTINATION license) + ${CMAKE_SOURCE_DIR}/LICENSE + DESTINATION license) install(FILES - ${CMAKE_SOURCE_DIR}/thirdparty_notice.txt - DESTINATION license) + ${CMAKE_SOURCE_DIR}/thirdparty_notice.txt + DESTINATION license) # Halide if (ION_BUNDLE_HALIDE) @@ -158,10 +158,10 @@ if (ION_BUNDLE_HALIDE) install(FILES ${HALIDE_HEADERS} DESTINATION include) file(GLOB HALIDE_BINS - ${HALIDE_ROOT}/bin/featurization_to_sample* - ${HALIDE_ROOT}/bin/get_host_target* - ${HALIDE_ROOT}/bin/retrain_cost_model* - ${HALIDE_ROOT}/bin/weightsdir_to_weightsfile*) + ${HALIDE_ROOT}/bin/featurization_to_sample* + ${HALIDE_ROOT}/bin/get_host_target* + ${HALIDE_ROOT}/bin/retrain_cost_model* + ${HALIDE_ROOT}/bin/weightsdir_to_weightsfile*) install(FILES ${HALIDE_BINS} DESTINATION bin) install(DIRECTORY ${HALIDE_ROOT}/lib/cmake/Halide DESTINATION lib/cmake/) diff --git a/example/gender_count.cc b/example/gender_count.cc index b8a01609..8a38bc5c 100644 --- a/example/gender_count.cc +++ b/example/gender_count.cc @@ -25,15 +25,26 @@ int main(int argc, char *argv[]) { n = b.add("base_reorder_buffer_3d_float")(n["output"]).set_param(Param{"dim0", "2"}, Param{"dim1", "0"}, Param{"dim2", "1"}); // CHW -> HWC auto img = n["output"]; + n = b.add("dnn_tlt_peoplenet")(img); + n = b.add("base_reorder_buffer_3d_float")(n["output"]).set_param(Param{"dim0", "1"}, Param{"dim1", "2"}, Param{"dim2", "0"}); // HWC -> CHW + n = b.add("base_denormalize_3d_uint8")(n["output"]); + n = b.add("image_io_gui_display")(n["output"]).set_param(wparam, hparam); Port out_p1 = n["output"]; + n = b.add("dnn_tlt_peoplenet_md")(img).set_param(wparam, hparam); + n = b.add("dnn_classify_gender")(img, n["output"]).set_param(wparam, hparam); + n = b.add("dnn_json_dict_average_regulator")(n["output"]).set_param(Param{"period_in_sec", "10"}); + n = b.add("dnn_ifttt_webhook_uploader")(n["output"]).set_param(Param{"ifttt_webhook_url", "http://maker.ifttt.com/trigger/gender_count/with/key/buf--6AoUjTGu868Pva_Q9"}); + Port out_p2 = n["output"]; + PortMap pm; pm.set(wport, width); pm.set(hport, height); Halide::Buffer out1 = Halide::Buffer::make_scalar(); pm.set(out_p1, out1); - - for (int i=0; i<10; ++i) { + Halide::Buffer out2 = Halide::Buffer::make_scalar(); + pm.set(out_p2, out2); + for (int i=0; i<1000; ++i) { b.run(pm); } } catch (const std::exception &e) { @@ -44,4 +55,4 @@ int main(int argc, char *argv[]) { } return 0; -} +} \ No newline at end of file diff --git a/include/ion/port_map.h b/include/ion/port_map.h index 523b100e..18a3c613 100644 --- a/include/ion/port_map.h +++ b/include/ion/port_map.h @@ -12,22 +12,22 @@ namespace std { - template<> - struct hash> +template<> +struct hash> { std::size_t operator()(const tuple& k) const noexcept -{ - return std::hash{}(std::get<0>(k)) ^ std::hash{}(std::get<1>(k)); -} + { + return std::hash{}(std::get<0>(k)) ^ std::hash{}(std::get<1>(k)); + } }; template<> struct equal_to> { -bool operator()(const tuple& v0, const tuple& v1) const -{ - return (std::get<0>(v0) == std::get<0>(v1) && std::get<1>(v0) == std::get<1>(v1)); -} + bool operator()(const tuple& v0, const tuple& v1) const + { + return (std::get<0>(v0) == std::get<0>(v1) && std::get<1>(v0) == std::get<1>(v1)); + } }; } // std @@ -37,135 +37,135 @@ namespace ion { /** * PortMap is used to assign actual value to the port input. */ - class PortMap { - - public: - - template - void set(const Halide::Param& p, T v) { - param_expr_[p.name()] = p; - param_map_.set(p, v); +class PortMap { + +public: + + template + void set(const Halide::Param& p, T v) { + param_expr_[p.name()] = p; + param_map_.set(p, v); + } + + template + void set(const Halide::ImageParam& p, Halide::Buffer &buf) { + param_func_[p.name()] = p; + param_map_.set(p, buf); + } + + /** + * Set the scalar value against to the port. + * Template type T is allowed to be one of the following. + * - bool + * - uint8_t + * - uint16_t + * - uint32_t + * - uint64_t + * - int8_t + * - int16_t + * - int32_t + * - int64_t + * - float + * - double + * @arg p: The port object which value is assigned. + * @arg v: Actual value to be mapped to the port. + */ + template + void set(Port p, T v) { + param_expr_[p.key()] = p.expr(); + p.set_to_param_map(param_map_, v); + } + + /** + * Set the vector value against to the port. + * Following type value is allowed to specified: + * - bool + * - uint8_t + * - uint16_t + * - uint32_t + * - uint64_t + * - int8_t + * - int16_t + * - int32_t + * - int64_t + * - float + * - double + * @arg p: The port object which value is assigned. + * @arg buf: Actual value to be mapped to the port. + * Buffer dimension should be matched with port's one. + */ + template + void set(Port p, Halide::Buffer &buf) { + if (p.bound()) { + // This is just an output. + output_buffer_[std::make_tuple(p.node_id(), p.key())] = { buf }; + } else { + param_func_[p.key()] = p.func(); + p.set_to_param_map(param_map_, buf); } - - template - void set(const Halide::ImageParam& p, Halide::Buffer &buf) { - param_func_[p.name()] = p; - param_map_.set(p, buf); - } - - /** - * Set the scalar value against to the port. - * Template type T is allowed to be one of the following. - * - bool - * - uint8_t - * - uint16_t - * - uint32_t - * - uint64_t - * - int8_t - * - int16_t - * - int32_t - * - int64_t - * - float - * - double - * @arg p: The port object which value is assigned. - * @arg v: Actual value to be mapped to the port. - */ - template - void set(Port p, T v) { - param_expr_[p.key()] = p.expr(); - p.set_to_param_map(param_map_, v); - } - - /** - * Set the vector value against to the port. - * Following type value is allowed to specified: - * - bool - * - uint8_t - * - uint16_t - * - uint32_t - * - uint64_t - * - int8_t - * - int16_t - * - int32_t - * - int64_t - * - float - * - double - * @arg p: The port object which value is assigned. - * @arg buf: Actual value to be mapped to the port. - * Buffer dimension should be matched with port's one. - */ - template - void set(Port p, Halide::Buffer &buf) { - if (p.bound()) { - // This is just an output. - output_buffer_[std::make_tuple(p.node_id(), p.key())] = { buf }; - } else { - param_func_[p.key()] = p.func(); - p.set_to_param_map(param_map_, buf); + } + + /** + * Set the vector of the vector values against to the port. + * Following type value is allowed to specified: + * - bool + * - uint8_t + * - uint16_t + * - uint32_t + * - uint64_t + * - int8_t + * - int16_t + * - int32_t + * - int64_t + * - float + * - double + * @arg p: The port object which value is assigned. + * @arg bufs: Actual value to be mapped to the port. + * Buffer dimension should be matched with port's one. + */ + template + void set(Port p, const std::vector> &bufs) { + if (p.bound()) { + // This is just an output. + + for (size_t i=0; i - void set(Port p, const std::vector> &bufs) { - if (p.bound()) { - // This is just an output. - - for (size_t i=0; i, std::vector>> get_output_buffer() const { + return output_buffer_; + } - std::unordered_map, std::vector>> get_output_buffer() const { - return output_buffer_; - } - - Halide::ParamMap get_param_map() const { - return param_map_; - } + Halide::ParamMap get_param_map() const { + return param_map_; + } - private: + private: - std::unordered_map param_expr_; - std::unordered_map param_func_; - std::unordered_map, std::vector>> output_buffer_; - Halide::ParamMap param_map_; - }; + std::unordered_map param_expr_; + std::unordered_map param_func_; + std::unordered_map, std::vector>> output_buffer_; + Halide::ParamMap param_map_; +}; } // namespace ion -#endif // ION_PORT_MAP_H +#endif // ION_PORT_MAP_H \ No newline at end of file From 322f32cc9f8e87ec79b15c583e14cf11443b80f8 Mon Sep 17 00:00:00 2001 From: xinyuli1204 Date: Thu, 30 Nov 2023 12:44:12 -0800 Subject: [PATCH 08/11] revert cmakefile and port_map --- CMakeLists.txt | 2 +- include/ion/port_map.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08a85ea4..bc8cd27f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -192,4 +192,4 @@ else () set(CPACK_GENERATOR "ZIP") endif () set(CPACK_PACKAGE_VERSION ${ION_KIT_VERSION}) -include(CPack) +include(CPack) \ No newline at end of file diff --git a/include/ion/port_map.h b/include/ion/port_map.h index 18a3c613..c6c4c3e8 100644 --- a/include/ion/port_map.h +++ b/include/ion/port_map.h @@ -168,4 +168,4 @@ class PortMap { } // namespace ion -#endif // ION_PORT_MAP_H \ No newline at end of file +#endif // ION_PORT_MAP_H From 57cbc207f4cc5ab73f67d8c714a6d9ccf7941ad6 Mon Sep 17 00:00:00 2001 From: xinyuli1204 Date: Thu, 30 Nov 2023 13:12:13 -0800 Subject: [PATCH 09/11] apply clang format --- CMakeLists.txt | 2 +- example/gender_count.cc | 2 +- src/bb/base/rt.h | 1 - src/bb/image-io/rt_common.h | 452 ++++++++++++++++++------------------ test/CMakeLists.txt | 7 +- 5 files changed, 228 insertions(+), 236 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bc8cd27f..08a85ea4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -192,4 +192,4 @@ else () set(CPACK_GENERATOR "ZIP") endif () set(CPACK_PACKAGE_VERSION ${ION_KIT_VERSION}) -include(CPack) \ No newline at end of file +include(CPack) diff --git a/example/gender_count.cc b/example/gender_count.cc index 8a38bc5c..2a4ca9ff 100644 --- a/example/gender_count.cc +++ b/example/gender_count.cc @@ -55,4 +55,4 @@ int main(int argc, char *argv[]) { } return 0; -} \ No newline at end of file +} diff --git a/src/bb/base/rt.h b/src/bb/base/rt.h index a057f3b3..d72d0780 100644 --- a/src/bb/base/rt.h +++ b/src/bb/base/rt.h @@ -133,7 +133,6 @@ extern "C" ION_EXPORT int ion_bb_base_buffer_loader(halide_buffer_t *url_buf, in } } } else { - httplib::Client cli(host_name.c_str()); cli.set_follow_location(true); auto res = cli.Get(path_name.c_str()); diff --git a/src/bb/image-io/rt_common.h b/src/bb/image-io/rt_common.h index 664a61e4..a865adc9 100644 --- a/src/bb/image-io/rt_common.h +++ b/src/bb/image-io/rt_common.h @@ -14,8 +14,6 @@ #include #endif - - #include "httplib.h" #include "zip_file.hpp" @@ -33,34 +31,34 @@ #endif namespace ion { - namespace bb { - namespace image_io { - - template - std::string format(const char *fmt, const Rest &... rest) { - int length = snprintf(NULL, 0, fmt, rest...) + 1; // Explicit place for null termination - std::vector buf(length, 0); - snprintf(&buf[0], length, fmt, rest...); - std::string s(buf.begin(), std::find(buf.begin(), buf.end(), '\0')); - return s; - } - - class DynamicModule { - public: +namespace bb { +namespace image_io { + +template +std::string format(const char *fmt, const Rest &... rest) { + int length = snprintf(NULL, 0, fmt, rest...) + 1; // Explicit place for null termination + std::vector buf(length, 0); + snprintf(&buf[0], length, fmt, rest...); + std::string s(buf.begin(), std::find(buf.begin(), buf.end(), '\0')); + return s; +} + +class DynamicModule { +public: #ifdef _WIN32 - using Handle = HMODULE; + using Handle = HMODULE; #else - using Handle = void *; + using Handle = void *; #endif - DynamicModule(const std::string &module_name, bool essential) { - if (module_name == "") { - handle_ = nullptr; - return; - } + DynamicModule(const std::string &module_name, bool essential) { + if (module_name == "") { + handle_ = nullptr; + return; + } #ifdef _WIN32 - auto file_name = module_name + ".dll"; + auto file_name = module_name + ".dll"; handle_ = LoadLibraryA(file_name.c_str()); if (handle_ != nullptr){ @@ -72,52 +70,52 @@ namespace ion { handle_ = LoadLibraryA(file_name.c_str()); #else - auto file_name = "lib" + module_name + ".so"; - handle_ = dlopen(file_name.c_str(), RTLD_NOW); + auto file_name = "lib" + module_name + ".so"; + handle_ = dlopen(file_name.c_str(), RTLD_NOW); #endif - if (handle_ == nullptr) { - if (essential) { - throw std::runtime_error(get_error_string()); - } else { - std::cerr << format("WARNING: Not found the not essential dynamic library: %s, it may work as a simulation mode", module_name.c_str()); - } - } - } + if (handle_ == nullptr) { + if (essential) { + throw std::runtime_error(get_error_string()); + } else { + std::cerr << format("WARNING: Not found the not essential dynamic library: %s, it may work as a simulation mode", module_name.c_str()); + } + } + } - ~DynamicModule() { - if (handle_ != nullptr) { + ~DynamicModule() { + if (handle_ != nullptr) { #ifdef _WIN32 - FreeLibrary(handle_); + FreeLibrary(handle_); #else - dlclose(handle_); + dlclose(handle_); #endif - } - } + } + } - DynamicModule(const std::string &module_name) - : DynamicModule(module_name, true) { - } + DynamicModule(const std::string &module_name) + : DynamicModule(module_name, true) { + } - bool is_available(void) const { - return handle_ != NULL; - } + bool is_available(void) const { + return handle_ != NULL; + } - template - T get_symbol(const std::string &symbol_name) const { + template + T get_symbol(const std::string &symbol_name) const { #if defined(_WIN32) - return reinterpret_cast(GetProcAddress(handle_, symbol_name.c_str())); + return reinterpret_cast(GetProcAddress(handle_, symbol_name.c_str())); #else - return reinterpret_cast(dlsym(handle_, symbol_name.c_str())); + return reinterpret_cast(dlsym(handle_, symbol_name.c_str())); #endif - } + } - private: - std::string get_error_string(void) const { - std::string error_msg; +private: + std::string get_error_string(void) const { + std::string error_msg; #ifdef _WIN32 - LPVOID lpMsgBuf; + LPVOID lpMsgBuf; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, GetLastError(), @@ -130,195 +128,195 @@ namespace ion { error_msg.assign(buf.begin(), buf.end()); LocalFree(lpMsgBuf); #else - const char *buf(dlerror()); - error_msg.assign(buf ? buf : "none"); + const char *buf(dlerror()); + error_msg.assign(buf ? buf : "none"); #endif - return error_msg; - } - - Handle handle_; - }; - - std::tuple parse_url(const std::string &url) { - auto protocol_end_pos = url.find("://"); - if (protocol_end_pos == std::string::npos) { - return std::tuple("", ""); - } - 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(host_name, path_name); - } + return error_msg; + } + + Handle handle_; +}; + +std::tuple parse_url(const std::string &url) { + auto protocol_end_pos = url.find("://"); + if (protocol_end_pos == std::string::npos) + return std::tuple("", ""); + 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(host_name, path_name); +} #ifndef _WIN32 - cv::Mat get_image(const std::string &url) { - if (url.empty()) { - return {}; - } - - std::string host_name; - std::string path_name; - std::tie(host_name, path_name) = parse_url(url); - cv::Mat img; - bool img_loaded = false; - if (host_name.empty() || path_name.empty()) { - // fallback to local file - img = cv::imread(url); - if (!img.empty()) { - img_loaded = true; - } - } else { -// 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()); - - if (res && res->status == 200) { - std::vector data(res->body.size()); - std::memcpy(data.data(), res->body.c_str(), res->body.size()); - img = cv::imdecode(cv::InputArray(data), cv::IMREAD_COLOR); - if (!img.empty()) { - img_loaded = true; - } - } - } +cv::Mat get_image(const std::string &url) { + if (url.empty()) { + return {}; + } + + std::string host_name; + std::string path_name; + std::tie(host_name, path_name) = parse_url(url); + + cv::Mat img; + bool img_loaded = false; + if (host_name.empty() || path_name.empty()) { + // fallback to local file + img = cv::imread(url); + if (!img.empty()) { + img_loaded = true; + } + } else { + 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) { + std::vector data(res->body.size()); + std::memcpy(data.data(), res->body.c_str(), res->body.size()); + img = cv::imdecode(cv::InputArray(data), cv::IMREAD_COLOR); + if (!img.empty()) { + img_loaded = true; + } + } + } + + if (img_loaded) { + return img; + } else { + return {}; + } +} + +class ImageSequence { + + public: + ImageSequence(const std::string& session_id, const std::string& url) : idx_(0) { + namespace fs = std::filesystem; + + std::string host_name; + std::string path_name; + std::tie(host_name, path_name) = ion::bb::image_io::parse_url(url); + + std::vector data; + if (host_name.empty() || path_name.empty()) { + // fallback to local file + data.resize(fs::file_size(url)); + std::ifstream ifs(url, std::ios::binary); + ifs.read(reinterpret_cast(data.data()), data.size()); + } else { + 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) { + data.resize(res->body.size()); + std::memcpy(data.data(), res->body.c_str(), res->body.size()); + } else { + throw std::runtime_error("Failed to download"); + } + } - if (img_loaded) { - return img; - } else { - return {}; - } + auto dir_path = fs::temp_directory_path() / session_id; + if (!fs::exists(dir_path)) { + if (!fs::create_directory(dir_path)) { + throw std::runtime_error("Failed to create temporary directory"); } + } - class ImageSequence { + if (fs::path(url).extension() == ".zip") { + miniz_cpp::zip_file zf(data); + zf.extractall(dir_path.string()); + } else { + std::ofstream ofs(dir_path / fs::path(url).filename(), std::ios::binary); + ofs.write(reinterpret_cast(data.data()), data.size()); + } - public: - ImageSequence(const std::string& session_id, const std::string& url) : idx_(0) { - namespace fs = std::filesystem; + for (auto& d : fs::directory_iterator(dir_path)) { + paths_.push_back(d.path()); + } + // Dictionary order + std::sort(paths_.begin(), paths_.end()); - std::string host_name; - std::string path_name; - std::tie(host_name, path_name) = ion::bb::image_io::parse_url(url); + } - std::vector data; - if (host_name.empty() || path_name.empty()) { - // fallback to local file - data.resize(fs::file_size(url)); - std::ifstream ifs(url, std::ios::binary); - ifs.read(reinterpret_cast(data.data()), data.size()); - } else { - 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) { - data.resize(res->body.size()); - std::memcpy(data.data(), res->body.c_str(), res->body.size()); - } else { - throw std::runtime_error("Failed to download"); - } - } + cv::Mat get(int width, int height, int imread_flags) { + namespace fs = std::filesystem; - auto dir_path = fs::temp_directory_path() / session_id; - if (!fs::exists(dir_path)) { - if (!fs::create_directory(dir_path)) { - throw std::runtime_error("Failed to create temporary directory"); - } - } + cv::Mat frame; - if (fs::path(url).extension() == ".zip") { - miniz_cpp::zip_file zf(data); - zf.extractall(dir_path.string()); - } else { - std::ofstream ofs(dir_path / fs::path(url).filename(), std::ios::binary); - ofs.write(reinterpret_cast(data.data()), data.size()); - } + auto path = paths_[idx_]; - for (auto& d : fs::directory_iterator(dir_path)) { - paths_.push_back(d.path()); + if (path.extension() == ".raw") { + auto size = fs::file_size(path); + switch (imread_flags) { + case cv::IMREAD_GRAYSCALE: + if (size == width * height * sizeof(uint8_t)) { + frame = cv::Mat(height, width, CV_8UC1); + } else if (size == width * height * sizeof(uint16_t)) { + frame = cv::Mat(height, width, CV_16UC1); + } else { + throw std::runtime_error("Unsupported raw format"); } - // Dictionary order - std::sort(paths_.begin(), paths_.end()); - - } - - cv::Mat get(int width, int height, int imread_flags) { - namespace fs = std::filesystem; - - cv::Mat frame; - auto path = paths_[idx_]; - if (path.extension() == ".raw") { - auto size = fs::file_size(path); - switch (imread_flags) { - case cv::IMREAD_GRAYSCALE: - if (size == width * height * sizeof(uint8_t)) { - frame = cv::Mat(height, width, CV_8UC1); - } else if (size == width * height * sizeof(uint16_t)) { - frame = cv::Mat(height, width, CV_16UC1); - } else { - throw std::runtime_error("Unsupported raw format"); - } - break; - case cv::IMREAD_COLOR: - if (size == 3 * width * height * sizeof(uint8_t)) { - // Expect interleaved RGB - frame = cv::Mat(height, width, CV_8UC3); - } else { - throw std::runtime_error("Unsupported raw format"); - } - break; - default: - throw std::runtime_error("Unsupported flags"); - } - std::ifstream ifs(path, std::ios::binary); - ifs.read(reinterpret_cast(frame.ptr()), size); + break; + case cv::IMREAD_COLOR: + if (size == 3 * width * height * sizeof(uint8_t)) { + // Expect interleaved RGB + frame = cv::Mat(height, width, CV_8UC3); } else { - frame = cv::imread(path.string(), imread_flags); - if (frame.empty()) { - throw std::runtime_error("Failed to load data : " + path.string()); - } + throw std::runtime_error("Unsupported raw format"); } - idx_ = ((idx_+1) % paths_.size()); + break; + default: + throw std::runtime_error("Unsupported flags"); + } + std::ifstream ifs(path, std::ios::binary); + ifs.read(reinterpret_cast(frame.ptr()), size); + } else { + frame = cv::imread(path.string(), imread_flags); + if (frame.empty()) { + throw std::runtime_error("Failed to load data : " + path.string()); + } + } + idx_ = ((idx_+1) % paths_.size()); - return frame; - } + return frame; + } - private: - int32_t idx_; - std::vector paths_; - }; + private: + int32_t idx_; + std::vector paths_; +}; #endif // _WIN32 - 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; - }; +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; +}; // PFNC // https://www.emva.org/wp-content/uploads/GenICamPixelFormatValues.pdf @@ -328,8 +326,8 @@ namespace ion { #define PFNC_RGB8 0x02180014 #define PFNC_BGR8 0x02180015 - } // namespace image_io - } // namespace bb +} // namespace image_io +} // namespace bb } // namespace ion #endif \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8d0894a0..cb7fbb75 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,9 +2,6 @@ # ion-core Testing # - - - # Test BB module add_library(ion-bb-test SHARED ion-bb-test.cc) if(UNIX) @@ -62,18 +59,16 @@ ion_jit(dup SRCS dup.cc) add_dependencies(dup ion-bb-test) ion_register_test(dup_test dup) - # Output error handling ion_jit(port-binding SRCS port-binding.cc) add_dependencies(port-binding ion-bb-test) ion_register_test(port-binding_test port-binding) -# Port index access ion_jit(port-access SRCS port-access.cc) add_dependencies(port-access ion-bb-test) ion_register_test(port-access_test port-access) - +# Port index access ion_jit(direct-extern SRCS direct-extern.cc) add_dependencies(direct-extern ion-bb-test) ion_register_test(direct-extern_test direct-extern) From 1b7962eaf6d1fb6062295290497848f4152d8791 Mon Sep 17 00:00:00 2001 From: xinyuli1204 Date: Thu, 30 Nov 2023 13:16:26 -0800 Subject: [PATCH 10/11] fix parse_url --- src/bb/base/rt.h | 20 ++++++++++---------- test/CMakeLists.txt | 3 ++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/bb/base/rt.h b/src/bb/base/rt.h index d72d0780..b95d1a1e 100644 --- a/src/bb/base/rt.h +++ b/src/bb/base/rt.h @@ -40,17 +40,17 @@ namespace ion { namespace bb { namespace base { - std::tuple parse_url(const std::string &url) { - auto protocol_end_pos = url.find("://"); - if (protocol_end_pos == std::string::npos) { - return std::tuple("", ""); - } - 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(host_name, path_name); +std::tuple parse_url(const std::string &url) { + auto protocol_end_pos = url.find("://"); + if (protocol_end_pos == std::string::npos) { + return std::tuple("", ""); } + 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(host_name, path_name); +} template void fill_by_rng(std::mt19937 &rng, halide_buffer_t *range, halide_buffer_t *out) { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index cb7fbb75..3608ca36 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -64,11 +64,12 @@ ion_jit(port-binding SRCS port-binding.cc) add_dependencies(port-binding ion-bb-test) ion_register_test(port-binding_test port-binding) +# Port index access ion_jit(port-access SRCS port-access.cc) add_dependencies(port-access ion-bb-test) ion_register_test(port-access_test port-access) -# Port index access + ion_jit(direct-extern SRCS direct-extern.cc) add_dependencies(direct-extern ion-bb-test) ion_register_test(direct-extern_test direct-extern) From 554ed8b6309220013fa28899ad86a4f6a962ed13 Mon Sep 17 00:00:00 2001 From: xinyuli1204 Date: Thu, 30 Nov 2023 13:19:13 -0800 Subject: [PATCH 11/11] fix cameraN --- src/bb/image-io/bb.h | 118 +++++++++++++++++++++---------------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/src/bb/image-io/bb.h b/src/bb/image-io/bb.h index fed6b9c2..5bd27ff2 100644 --- a/src/bb/image-io/bb.h +++ b/src/bb/image-io/bb.h @@ -321,82 +321,82 @@ class Camera2 : public ion::BuildingBlock { class CameraN : public ion::BuildingBlock { - public: - GeneratorParam num_devices{"num_devices", 2}; - GeneratorParam gc_title{"gc_title", "USBCamera"}; - GeneratorParam gc_description{"gc_description", "This captures USB camera image."}; - GeneratorParam gc_tags{"gc_tags", "input,sensor"}; - GeneratorParam gc_inference{"gc_inference", R"((function(v){ return { output: [parseInt(v.width), parseInt(v.height), 3] }}))"}; - GeneratorParam gc_mandatory{"gc_mandatory", "width,height"}; - GeneratorParam gc_strategy{"gc_strategy", "self"}; - GeneratorParam gc_prefix{"gc_prefix", ""}; - - GeneratorParam fps{"fps", 30}; - GeneratorParam width{"width", 0}; - GeneratorParam height{"height", 0}; - GeneratorParam index{"index", 0}; - GeneratorParam urls{"urls", ""}; - -// GeneratorInput[]> urls{"urls"}; - GeneratorOutput output{"output", Halide::type_of(), 3}; - - - void generate() { - - std::stringstream urls_stream(urls); - std::string url; - std::vector url_list; - while(std::getline(urls_stream, url, ';')) - { - url_list.push_back(url); - } +public: + GeneratorParam num_devices{"num_devices", 2}; + GeneratorParam gc_title{"gc_title", "USBCamera"}; + GeneratorParam gc_description{"gc_description", "This captures USB camera image."}; + GeneratorParam gc_tags{"gc_tags", "input,sensor"}; + GeneratorParam gc_inference{"gc_inference", R"((function(v){ return { output: [parseInt(v.width), parseInt(v.height), 3] }}))"}; + GeneratorParam gc_mandatory{"gc_mandatory", "width,height"}; + GeneratorParam gc_strategy{"gc_strategy", "self"}; + GeneratorParam gc_prefix{"gc_prefix", ""}; + GeneratorParam fps{"fps", 30}; + GeneratorParam width{"width", 0}; + GeneratorParam height{"height", 0}; + GeneratorParam index{"index", 0}; + GeneratorParam urls{"urls", ""}; - using namespace Halide; +// GeneratorInput[]> urls{"urls"}; + GeneratorOutput output{"output", Halide::type_of(), 3}; - output.resize(num_devices); - for (int i =0; i < num_devices; i++){ - std::string url_str; - if (url_list.size()!=0){ - url_str = url_list[i]; - } - else{ - url_str = ""; - } + void generate() { + std::stringstream urls_stream(urls); + std::string url; + std::vector url_list; + while(std::getline(urls_stream, url, ';')) + { + url_list.push_back(url); + } - Halide::Buffer url_buf(url_str.size() + 1); - url_buf.fill(0); - std::memcpy(url_buf.data(), url_str.c_str(), url_str.size()); + using namespace Halide; - std::vector params = {instance_id++, cast(index), cast(fps), cast(width), cast(height), url_buf}; - Func camera(static_cast(gc_prefix) + "camera"); - camera.define_extern("ion_bb_image_io_camera", params, Halide::type_of(), 2); - camera.compute_root(); + output.resize(num_devices); - Func camera_ = BoundaryConditions::repeat_edge(camera, {{0, 2 * width}, {0, height}}); + for (int i =0; i < num_devices; i++){ + std::string url_str; + if (url_list.size()!=0){ + url_str = url_list[i]; + } + else{ + url_str = ""; + } - Var c, x, y; - Expr yv = cast(camera_(2 * x, y)); - Expr uv = cast(camera_(select((x & 1) == 0, 2 * x + 1, 2 * x - 1), y)); - Expr vv = cast(camera_(select((x & 1) == 0, 2 * x + 3, 2 * x + 1), y)); - Expr f128 = cast(128); - Expr r = saturating_cast(yv + cast(1.403f) * (vv - f128)); - Expr g = saturating_cast(yv - cast(0.344f) * (uv - f128) - (cast(0.714f) * (vv - f128))); - Expr b = saturating_cast(yv + cast(1.773f) * (uv - f128)); + Halide::Buffer url_buf(url_str.size() + 1); + url_buf.fill(0); + std::memcpy(url_buf.data(), url_str.c_str(), url_str.size()); + std::vector params = {instance_id++, cast(index), cast(fps), cast(width), cast(height), url_buf}; + Func camera(static_cast(gc_prefix) + "camera"); + camera.define_extern("ion_bb_image_io_camera", params, Halide::type_of(), 2); + camera.compute_root(); - Func f(static_cast(gc_prefix) + "output" + std::to_string(i)); - f(x, y, c) = mux(c, {r, g, b}); + Func camera_ = BoundaryConditions::repeat_edge(camera, {{0, 2 * width}, {0, height}}); - output[i](_) = f(_); - } + Var c, x, y; + Expr yv = cast(camera_(2 * x, y)); + Expr uv = cast(camera_(select((x & 1) == 0, 2 * x + 1, 2 * x - 1), y)); + Expr vv = cast(camera_(select((x & 1) == 0, 2 * x + 3, 2 * x + 1), y)); + + Expr f128 = cast(128); + Expr r = saturating_cast(yv + cast(1.403f) * (vv - f128)); + Expr g = saturating_cast(yv - cast(0.344f) * (uv - f128) - (cast(0.714f) * (vv - f128))); + Expr b = saturating_cast(yv + cast(1.773f) * (uv - f128)); + + + Func f(static_cast(gc_prefix) + "output" + std::to_string(i)); + f(x, y, c) = mux(c, {r, g, b}); + + output[i](_) = f(_); } + + } };