onnx.sh 4.81 KB
Newer Older
sunzhq2's avatar
init  
sunzhq2 committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash

# # 定义输入模型路径和输出模型路径的基本部分
# input_model="./model_zoo/regular/open_resnet50/resnet50-torch-fp32.onnx"
# output_model_base="./model_zoo/regular/open_resnet50/resnet50-mir-fp32"

# # 定义不同的批量大小
# batch_sizes=(1 32 64 128 256 512 1024 2048)  # 根据需要可以调整

# # 循环遍历每个批量大小
# for bs in "${batch_sizes[@]}"; do
#     # 构造输出模型文件名
#     output_model="${output_model_base}-${bs}.onnx"
    
#     # 构造 input_shape_dict
#     input_shape_dict="{'input_1.1': [${bs}, 3, 224, 224]}"
    
#     # 执行转换命令
#     command="python -m paddle2onnx.optimize --input_model ${input_model} --output_model ${output_model} --input_shape_dict=\"${input_shape_dict}\""
    
#     # 打印命令以供调试
#     echo "Executing: ${command}"
    
#     # 执行命令
#     eval "${command}"
# done


# # 定义输入模型路径和输出模型路径的基本部分
# input_model="./model_zoo/regular/open_resnet50/resnet50-torch-fp16.onnx"
# output_model_base="./model_zoo/regular/open_resnet50/resnet50-mir-fp16"

# # 定义不同的批量大小
# batch_sizes=(1 32 64 128 256 512 1024 2048)  # 根据需要可以调整

# # 循环遍历每个批量大小
# for bs in "${batch_sizes[@]}"; do
#     # 构造输出模型文件名
#     output_model="${output_model_base}-${bs}.onnx"
    
#     # 构造 input_shape_dict
#     input_shape_dict="{'input_1.1': [${bs}, 3, 224, 224]}"
    
#     # 执行转换命令
#     command="python -m paddle2onnx.optimize --input_model ${input_model} --output_model ${output_model} --input_shape_dict=\"${input_shape_dict}\""
    
#     # 打印命令以供调试
#     echo "Executing: ${command}"
    
#     # 执行命令
#     eval "${command}"
# done


# 定义输入模型路径和输出模型路径的基本部分
input_model="/home/workspace/ByteMLPerf/byte_infer_perf/general_perf/test/bert-best-fp16.onnx"
output_model_base="/home/workspace/ByteMLPerf/byte_infer_perf/general_perf/test/bert-mir-fp16"

# 定义不同的批量大小
batch_sizes=(1 32 64 128)  # 根据需要可以调整

# 循环遍历每个批量大小
for bs in "${batch_sizes[@]}"; do
    # 构造输出模型文件名
    output_model="${output_model_base}-${bs}.onnx"
    
    # 构造 input_shape_dict
    input_shape_dict="{'input_ids.1': [${bs},384], 'attention_mask.1': [${bs},384], 'token_type_ids.1': [${bs},384]}"
    
    # 执行转换命令
    command="python -m paddle2onnx.optimize --input_model ${input_model} --output_model ${output_model} --input_shape_dict=\"${input_shape_dict}\""
    
    # 打印命令以供调试
    echo "Executing: ${command}"
    
    # 执行命令
    eval "${command}"
done


# 定义输入模型路径和输出模型路径的基本部分
# input_model="./model_zoo/regular/open_wide_deep_saved_model/widedeep-onnx-fp32.onnx"
# output_model_base="./model_zoo/regular/open_wide_deep_saved_model/widedeep-mir-fp32"

# # 定义不同的批量大小
# # batch_sizes=(1 1024 20000 40000 80000 120000)  # 根据需要可以调整
# batch_sizes=(140000 160000 180000 200000 220000 240000 260000)

# # 循环遍历每个批量大小
# for bs in "${batch_sizes[@]}"; do

#     new_value=$((bs * 26))
#     # 构造输出模型文件名
#     output_model="${output_model_base}-${bs}.onnx"
    
#     # 构造 input_shape_dict
#     input_shape_dict="{'new_categorical_placeholder:0': [${new_value}, 2], 'new_numeric_placeholder:0': [${bs}, 13]}"
    
#     # 执行转换命令
#     command="python -m paddle2onnx.optimize --input_model ${input_model} --output_model ${output_model} --input_shape_dict=\"${input_shape_dict}\""
    
#     # 打印命令以供调试
#     echo "Executing: ${command}"
    
#     # 执行命令
#     eval "${command}"
# done


# 定义输入模型路径和输出模型路径的基本部分
# input_model="./model_zoo/regular/open_wide_deep_saved_model/widedeep-onnx-fp16.onnx"
# output_model_base="./model_zoo/regular/open_wide_deep_saved_model/widedeep-mir-fp16"

# # 定义不同的批量大小
# # batch_sizes=(1 1024 20000 40000 80000 120000)  # 根据需要可以调整
# batch_sizes=(1 1024 20000 40000 80000 120000 140000 160000 180000 200000 220000 240000 260000)
# # 循环遍历每个批量大小
# for bs in "${batch_sizes[@]}"; do

#     new_value=$((bs * 26))
#     # 构造输出模型文件名
#     output_model="${output_model_base}-${bs}.onnx"
    
#     # 构造 input_shape_dict
#     input_shape_dict="{'new_categorical_placeholder:0': [${new_value}, 2], 'new_numeric_placeholder:0': [${bs}, 13]}"
    
#     # 执行转换命令
#     command="python -m paddle2onnx.optimize --input_model ${input_model} --output_model ${output_model} --input_shape_dict=\"${input_shape_dict}\""
    
#     # 打印命令以供调试
#     echo "Executing: ${command}"
    
#     # 执行命令
#     eval "${command}"
# done