# Loop through all .onnx files in the current directory | |
for model in ./*.onnx; do | |
# Exclude processing any files that already have a batch size in their name | |
if [[ ! $model =~ _batch[0-9]+\.onnx$ ]]; then | |
# Process for batch size 1 | |
python3 -m onnxruntime.tools.make_dynamic_shape_fixed --dim_param batch --dim_value 1 "$model" "${model%.onnx}_batch1.onnx" | |
echo "Generated ${model%.onnx}_batch1.onnx" | |
# Process for batch size 2 | |
python3 -m onnxruntime.tools.make_dynamic_shape_fixed --dim_param batch --dim_value 2 "$model" "${model%.onnx}_batch2.onnx" | |
echo "Generated ${model%.onnx}_batch2.onnx" | |
# Process for batch size 4 | |
python3 -m onnxruntime.tools.make_dynamic_shape_fixed --dim_param batch --dim_value 4 "$model" "${model%.onnx}_batch4.onnx" | |
echo "Generated ${model%.onnx}_batch4.onnx" | |
fi | |
done | |