From 51671ccc4254899b230986aab188dbbc7b735b1c Mon Sep 17 00:00:00 2001 From: chenyx113 Date: Mon, 17 Feb 2025 21:32:08 +0800 Subject: [PATCH 1/3] [tools/onnx-subgraph] Add test model downloading scripts Add test onnx models downloading scripts for future smoking test ONE-DCO-1.0-Signed-off-by: Youxin Chen --- tools/onnx_subgraph/CMakeLists.txt | 26 ++++++++++++++++++++++ tools/onnx_subgraph/test_model_download.sh | 15 +++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 tools/onnx_subgraph/test_model_download.sh diff --git a/tools/onnx_subgraph/CMakeLists.txt b/tools/onnx_subgraph/CMakeLists.txt index 29d8ab64d52..e16ae49f76f 100644 --- a/tools/onnx_subgraph/CMakeLists.txt +++ b/tools/onnx_subgraph/CMakeLists.txt @@ -13,3 +13,29 @@ find_package(Python3 COMPONENTS Interpreter Development REQUIRED) include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${Python3_INCLUDE_DIRS}) + +set(ONNX_SUGRAPH_FILES + test_model_download.sh + ) + + foreach(ONNX_SUGRAPH IN ITEMS ${ONNX_SUGRAPH_FILES}) + set(ONNX_SUGRAPH_FILE ${ONNX_SUGRAPH}) + set(ONNX_SUGRAPH_SRC "${CMAKE_CURRENT_SOURCE_DIR}/${ONNX_SUGRAPH_FILE}") + set(ONNX_SUGRAPH_BIN "${CMAKE_CURRENT_BINARY_DIR}/scripts/${ONNX_SUGRAPH_FILE}") + set(ONNX_SUGRAPH_TARGET "${ONNX_SUGRAPH}_target") + + add_custom_command(OUTPUT ${ONNX_SUGRAPH_BIN} + COMMAND ${CMAKE_COMMAND} -E copy "${ONNX_SUGRAPH_SRC}" "${ONNX_SUGRAPH_BIN}" + DEPENDS ${ONNX_SUGRAPH_SRC} + COMMENT "Generate ${ONNX_SUGRAPH_BIN}" + ) + + add_custom_target(${ONNX_SUGRAPH_TARGET} ALL DEPENDS ${ONNX_SUGRAPH_BIN}) + + install(FILES ${ONNX_SUGRAPH_BIN} + PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + DESTINATION bin) + + endforeach(ONNX_SUGRAPH) diff --git a/tools/onnx_subgraph/test_model_download.sh b/tools/onnx_subgraph/test_model_download.sh new file mode 100644 index 00000000000..09e1b027c62 --- /dev/null +++ b/tools/onnx_subgraph/test_model_download.sh @@ -0,0 +1,15 @@ +pip install onnx onnxsim + +if [ ! -d "./models/" ];then + mkdir ./models/ + else + echo "./models path existing" +fi + +cd ./models +wget https://media.githubusercontent.com/media/onnx/models/refs/heads/main/Computer_Vision/resnext26ts_Opset16_timm/resnext26ts_Opset16.onnx --no-check-certificate +#wget https://media.githubusercontent.com/media/onnx/models/refs/heads/main/Natural_Language_Processing/xmod_Opset16_transformers/xmod_Opset16.onnx --no-check-certificate + +onnxsim resnext26ts_Opset16.onnx ../resnet-test.onnx +#onnxsim xmod_Opset16.onnx ../xmod-transformer-test.onnx + From 950c2e48483f9310748fd55cb615a6b6f3afd7ab Mon Sep 17 00:00:00 2001 From: chenyx113 Date: Tue, 18 Feb 2025 19:50:08 +0800 Subject: [PATCH 2/3] [tools/onnx-subgraph]update code as PR reviews modify the indent issue, remove useless code, add shebang in bash script, modify the typing mistake ONE-DCO-1.0-Signed-off-by: Youxin Chen --- tools/onnx_subgraph/CMakeLists.txt | 45 ++++++++++------------ tools/onnx_subgraph/test_model_download.sh | 13 ++----- 2 files changed, 25 insertions(+), 33 deletions(-) diff --git a/tools/onnx_subgraph/CMakeLists.txt b/tools/onnx_subgraph/CMakeLists.txt index e16ae49f76f..b6727d7f2e8 100644 --- a/tools/onnx_subgraph/CMakeLists.txt +++ b/tools/onnx_subgraph/CMakeLists.txt @@ -14,28 +14,25 @@ find_package(Python3 COMPONENTS Interpreter Development REQUIRED) include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${Python3_INCLUDE_DIRS}) -set(ONNX_SUGRAPH_FILES +set(ONNX_SUBGRAPH_FILES test_model_download.sh - ) - - foreach(ONNX_SUGRAPH IN ITEMS ${ONNX_SUGRAPH_FILES}) - set(ONNX_SUGRAPH_FILE ${ONNX_SUGRAPH}) - set(ONNX_SUGRAPH_SRC "${CMAKE_CURRENT_SOURCE_DIR}/${ONNX_SUGRAPH_FILE}") - set(ONNX_SUGRAPH_BIN "${CMAKE_CURRENT_BINARY_DIR}/scripts/${ONNX_SUGRAPH_FILE}") - set(ONNX_SUGRAPH_TARGET "${ONNX_SUGRAPH}_target") - - add_custom_command(OUTPUT ${ONNX_SUGRAPH_BIN} - COMMAND ${CMAKE_COMMAND} -E copy "${ONNX_SUGRAPH_SRC}" "${ONNX_SUGRAPH_BIN}" - DEPENDS ${ONNX_SUGRAPH_SRC} - COMMENT "Generate ${ONNX_SUGRAPH_BIN}" - ) - - add_custom_target(${ONNX_SUGRAPH_TARGET} ALL DEPENDS ${ONNX_SUGRAPH_BIN}) - - install(FILES ${ONNX_SUGRAPH_BIN} - PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE - GROUP_READ GROUP_EXECUTE - WORLD_READ WORLD_EXECUTE - DESTINATION bin) - - endforeach(ONNX_SUGRAPH) +) +foreach(ONNX_SUBGRAPH IN ITEMS ${ONNX_SUBGRAPH_FILES}) + set(ONNX_SUBGRAPH_FILE ${ONNX_SUBGRAPH}) + set(ONNX_SUBGRAPH_SRC "${CMAKE_CURRENT_SOURCE_DIR}/${ONNX_SUBGRAPH_FILE}") + set(ONNX_SUBGRAPH_BIN "${CMAKE_CURRENT_BINARY_DIR}/scripts/${ONNX_SUBGRAPH_FILE}") + set(ONNX_SUBGRAPH_TARGET "${ONNX_SUBGRAPH}_target") + + add_custom_command(OUTPUT ${ONNX_SUBGRAPH_BIN} + COMMAND ${CMAKE_COMMAND} -E copy "${ONNX_SUBGRAPH_SRC}" "${ONNX_SUBGRAPH_BIN}" + DEPENDS ${ONNX_SUBGRAPH_SRC} + COMMENT "Generate ${ONNX_SUBGRAPH_BIN}" + ) + add_custom_target(${ONNX_SUBGRAPH_TARGET} ALL DEPENDS ${ONNX_SUBGRAPH_BIN}) + install(FILES ${ONNX_SUBGRAPH_BIN} + PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + DESTINATION bin + ) +endforeach(ONNX_SUBGRAPH) diff --git a/tools/onnx_subgraph/test_model_download.sh b/tools/onnx_subgraph/test_model_download.sh index 09e1b027c62..319d2940fc9 100644 --- a/tools/onnx_subgraph/test_model_download.sh +++ b/tools/onnx_subgraph/test_model_download.sh @@ -1,15 +1,10 @@ -pip install onnx onnxsim +#!/bin/bash -if [ ! -d "./models/" ];then - mkdir ./models/ - else - echo "./models path existing" -fi +pip install --user onnx onnxsim + +mkdir -p models cd ./models wget https://media.githubusercontent.com/media/onnx/models/refs/heads/main/Computer_Vision/resnext26ts_Opset16_timm/resnext26ts_Opset16.onnx --no-check-certificate -#wget https://media.githubusercontent.com/media/onnx/models/refs/heads/main/Natural_Language_Processing/xmod_Opset16_transformers/xmod_Opset16.onnx --no-check-certificate onnxsim resnext26ts_Opset16.onnx ../resnet-test.onnx -#onnxsim xmod_Opset16.onnx ../xmod-transformer-test.onnx - From 567c0aa9d67aa9a107ca15fab63a311f0cefa544 Mon Sep 17 00:00:00 2001 From: chenyx113 Date: Wed, 19 Feb 2025 07:28:21 +0800 Subject: [PATCH 3/3] [tools/onnx-subgraph]remove pip install as PR reviews remove the pip install in the bash script ONE-DCO-1.0-Signed-off-by: Youxin Chen --- tools/onnx_subgraph/test_model_download.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/onnx_subgraph/test_model_download.sh b/tools/onnx_subgraph/test_model_download.sh index 319d2940fc9..fade6e7391d 100644 --- a/tools/onnx_subgraph/test_model_download.sh +++ b/tools/onnx_subgraph/test_model_download.sh @@ -1,7 +1,5 @@ #!/bin/bash -pip install --user onnx onnxsim - mkdir -p models cd ./models