-
Notifications
You must be signed in to change notification settings - Fork 4.4k
[feat](benchmark): replace load_param with load_param_mem #6286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+175
−54
Merged
Changes from 8 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
a555f51
[feat](benchmark): replace load_param with load_param_mem
0130w f4999de
[docs](benchmark): update benchmark docs
0130w 1643c32
Merge branch 'master' into dev
0130w 41745c8
fix
0130w aae6ad8
Merge branch 'master' into dev
0130w 74ae9d1
refactor(benchmark): remove model registry and optimize param loading
0130w 086e73c
fix(benchmark): correct README param description
0130w 41f463d
refactor(benchmark): rename header file
0130w 1116143
Merge branch 'master' into dev
nihui b1fbd2e
wip
nihui 49b6e6c
Update cmake/ncnn_generate_param_header.cmake
nihui c6bf3cc
Update benchmark/benchncnn.cpp
nihui b181924
Update cmake/ncnn_add_param.cmake
nihui 8132739
Update benchncnn.cpp
nihui 77e57d7
w
nihui 8293ab9
Revert "w"
nihui b5b6558
Merge branch 'master' into dev
nihui 85399e8
update doc
nihui File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
|
|
||
| macro(ncnn_convert_param_file PARAM_FILE) | ||
| # Use a macro to convert the contents of a single parameter file into memory content | ||
| file(READ ${PARAM_FILE} param_file_data) | ||
|
|
||
| # remove whitespace | ||
nihui marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| string(REGEX REPLACE "\n +" "\n" param_file_data ${param_file_data}) | ||
|
|
||
| # remove empty line | ||
nihui marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| string(REGEX REPLACE "\n\n" "\n" param_file_data ${param_file_data}) | ||
nihui marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # Get the file name with extension | ||
| get_filename_component(PARAM_FILE_NAME ${PARAM_FILE} NAME) | ||
| # Manually remove ".param" since NAME_WE treats ".1.param" as a multi-extension | ||
| string(REPLACE ".param" "" PARAM_FILE_NAME_WE "${PARAM_FILE_NAME}") | ||
| # Replace characters invalid in C identifiers ('.' and '-') with underscores | ||
| string(REPLACE "." "_" PARAM_FILE_NAME_WE "${PARAM_FILE_NAME_WE}") | ||
| string(REPLACE "-" "_" PARAM_FILE_NAME_WE "${PARAM_FILE_NAME_WE}") | ||
| # Check if the result is empty | ||
| if (NOT PARAM_FILE_NAME_WE) | ||
| message(FATAL_ERROR "Failed to extract valid filename from '${PARAM_FILE}'") | ||
| endif() | ||
| # Check if the extracted filename is a valid C identifier | ||
| string(REGEX MATCH "^[A-Za-z_][A-Za-z0-9_]*$" is_valid "${PARAM_FILE_NAME_WE}") | ||
| if (NOT is_valid) | ||
| message(FATAL_ERROR "Extracted filename '${PARAM_FILE_NAME_WE}' is not a valid C identifier") | ||
| endif() | ||
|
|
||
| # text to hex | ||
| file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/param_hex_data/${PARAM_FILE_NAME_WE}.text2hex.txt "${param_file_data}") | ||
| file(READ ${CMAKE_CURRENT_BINARY_DIR}/param_hex_data/${PARAM_FILE_NAME_WE}.text2hex.txt param_file_data_hex HEX) | ||
| string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," param_file_data_hex ${param_file_data_hex}) | ||
| string(FIND "${param_file_data_hex}" "," tail_comma REVERSE) | ||
| string(SUBSTRING "${param_file_data_hex}" 0 ${tail_comma} param_file_data_hex) | ||
|
|
||
| # generate model param header file | ||
| file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/model_param_header/${PARAM_FILE_NAME_WE}.comp.hex.h "static const char ${PARAM_FILE_NAME_WE}_param_data[] = {${param_file_data_hex},0x00};\n") | ||
|
|
||
| # append include line to a CMake variable for later output | ||
| string(APPEND embedded_model_param_includes "#include \"model_param_header/${PARAM_FILE_NAME_WE}.comp.hex.h\"\n") | ||
| endmacro() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.