Skip to content

feat(benchmark/benchncnn.cpp): support user defined case#4782

Merged
nihui merged 11 commits intoTencent:masterfrom
tpoisonooo:benchncnn-support-user-specify
Aug 11, 2023
Merged

feat(benchmark/benchncnn.cpp): support user defined case#4782
nihui merged 11 commits intoTencent:masterfrom
tpoisonooo:benchncnn-support-user-specify

Conversation

@tpoisonooo
Copy link
Copy Markdown
Contributor

@tpoisonooo tpoisonooo commented Jun 6, 2023

benchncnn 支持指定 param 文件

1. 兼容原行为

$ ./benchncnn
$ ./benchncnn  8
..
$ ./benchncnn 1 8 0 -1 1 param=vgg16.param "shape=[112,112,3]"
loop_count = 1
num_threads = 8
powersave = 0
gpu_device = -1
cooling_down = 1
         vgg16.param  min =   28.64  max =   28.64  avg =   28.64

2. 发现输入 -h 或者 --help 打印 usage

$ ./benchncnn -h
Usage: benchncnn [loop count] [num threads] [powersave] [gpu device] [cooling down] [(key=value)...]
  param=model.param
  shape=[227,227,3],...
$ ./benchncnn 12 --help
Usage: benchncnn [loop count] [num threads] [powersave] [gpu device] [cooling down] [(key=value)...]
  param=model.param
  shape=[227,227,3],...

3. 增加指定 param 和 shape

shape 用 whc 格式

$ ./benchncnn 1 8 0 0 1 param=squeezenet.param "shape=[224,224,3]"
loop_count = 1
num_threads = 8
powersave = 0
gpu_device = 0
cooling_down = 1
    squeezenet.param  min =   11.40  max =   11.40  avg =   11.40

4. 异常处理:没输入shape

$ ./benchncnn 1 8 0 0 1 param=squeezenet.param                    
input tensor shape empty!

5. 异常处理:shape 输入了 4 维

$ ./benchncnn 1 8 0 0 1 param=squeezenet.param "shape=[224,224,3,1]"
unsupported input shape size 4
input tensor shape empty!

6. 模型只需要 1 个输入,输入了 2 个 shape

正常运行,此时取第一个 shape

$ ./benchncnn 1 8 0 0 1 param=squeezenet.param "shape=[224,224,3],[666]" 
loop_count = 1
num_threads = 8
powersave = 0
gpu_device = 0
cooling_down = 1
    squeezenet.param  min =    9.09  max =    9.09  avg =    9.09

@tpoisonooo tpoisonooo force-pushed the benchncnn-support-user-specify branch from d542486 to 14edf38 Compare June 6, 2023 08:31
@tpoisonooo tpoisonooo closed this Jun 6, 2023
@tpoisonooo tpoisonooo reopened this Jun 6, 2023
@tpoisonooo
Copy link
Copy Markdown
Contributor Author

rebase 一下 master. done.

@nihui
Copy link
Copy Markdown
Member

nihui commented Jun 12, 2023

参考 pnnx main.cpp,额外的高级参数采用 [(key=value)...] 的形式,有更好的扩展性,比如多输入

./benchncnn 20 1 1 -1 1
./benchncnn 20 1 1 -1 1 param=/home/khj/ncnn/benchmark/squeezenet.param shape=[227,227,3]
./benchncnn 20 1 1 -1 1 param=/home/khj/ncnn/benchmark/squeezenet.param shape=[227,227,3],[10],[1,1,1]

@tpoisonooo
Copy link
Copy Markdown
Contributor Author

done.

@tpoisonooo tpoisonooo changed the title feat(benchmark/benchncnn.cpp): support user defined case WIP feat(benchmark/benchncnn.cpp): support user defined case Jul 12, 2023
@tpoisonooo tpoisonooo changed the title WIP feat(benchmark/benchncnn.cpp): support user defined case feat(benchmark/benchncnn.cpp): support user defined case Jul 12, 2023
@tpoisonooo
Copy link
Copy Markdown
Contributor Author

@nihui 每日一催

@tpoisonooo
Copy link
Copy Markdown
Contributor Author

@nihui 每周一催

Comment thread benchmark/benchncnn.cpp Outdated
Comment thread benchmark/benchncnn.cpp Outdated
Comment thread benchmark/benchncnn.cpp Outdated
Comment thread benchmark/benchncnn.cpp Outdated
Comment thread benchmark/benchncnn.cpp Outdated
Comment thread benchmark/benchncnn.cpp Outdated
Comment thread benchmark/benchncnn.cpp Outdated
@tpoisonooo
Copy link
Copy Markdown
Contributor Author

@nihui 每月一催

@tpoisonooo
Copy link
Copy Markdown
Contributor Author

@nihui 日催

@nihui nihui merged commit a24787b into Tencent:master Aug 11, 2023
@nihui
Copy link
Copy Markdown
Member

nihui commented Aug 11, 2023

Thanks for your contribution !

@tpoisonooo 合并啦!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants