mirror of
https://github.com/k2-fsa/icefall.git
synced 2025-08-26 10:16:14 +00:00
Install onnxoptimizer
This commit is contained in:
parent
10ae39f8ab
commit
589eb626f9
2
.github/scripts/audioset/AT/run.sh
vendored
2
.github/scripts/audioset/AT/run.sh
vendored
@ -2,6 +2,8 @@
|
||||
|
||||
set -ex
|
||||
|
||||
python3 -m pip install onnxoptimizer
|
||||
|
||||
log() {
|
||||
# This function is from espnet
|
||||
local fname=${BASH_SOURCE[1]##*/}
|
||||
|
1
.github/scripts/docker/Dockerfile
vendored
1
.github/scripts/docker/Dockerfile
vendored
@ -49,6 +49,7 @@ RUN pip install --no-cache-dir \
|
||||
multi_quantization \
|
||||
numba \
|
||||
numpy \
|
||||
onnxoptimizer \
|
||||
onnx \
|
||||
onnxmltools \
|
||||
onnxruntime \
|
||||
|
@ -55,6 +55,7 @@ RUN pip install --no-cache-dir \
|
||||
onnx \
|
||||
onnxruntime \
|
||||
onnxmltools \
|
||||
onnxoptimizer \
|
||||
multi_quantization \
|
||||
typeguard \
|
||||
numpy \
|
||||
|
@ -55,6 +55,7 @@ RUN pip install --no-cache-dir \
|
||||
onnx \
|
||||
onnxruntime \
|
||||
onnxmltools \
|
||||
onnxoptimizer \
|
||||
multi_quantization \
|
||||
typeguard \
|
||||
numpy \
|
||||
|
@ -69,6 +69,7 @@ RUN pip uninstall -y tqdm && \
|
||||
onnx \
|
||||
onnxruntime \
|
||||
onnxmltools \
|
||||
onnxoptimizer \
|
||||
multi_quantization \
|
||||
typeguard \
|
||||
numpy \
|
||||
|
@ -56,6 +56,7 @@ RUN pip install --no-cache-dir \
|
||||
onnx \
|
||||
onnxruntime \
|
||||
onnxmltools \
|
||||
onnxoptimizer \
|
||||
multi_quantization \
|
||||
typeguard \
|
||||
numpy \
|
||||
|
@ -56,6 +56,7 @@ RUN pip install --no-cache-dir \
|
||||
onnx \
|
||||
onnxruntime \
|
||||
onnxmltools \
|
||||
onnxoptimizer \
|
||||
multi_quantization \
|
||||
typeguard \
|
||||
numpy \
|
||||
|
@ -56,6 +56,7 @@ RUN pip install --no-cache-dir \
|
||||
onnx \
|
||||
onnxruntime \
|
||||
onnxmltools \
|
||||
onnxoptimizer \
|
||||
multi_quantization \
|
||||
typeguard \
|
||||
numpy \
|
||||
|
@ -56,6 +56,7 @@ RUN pip install --no-cache-dir \
|
||||
onnx \
|
||||
onnxruntime \
|
||||
onnxmltools \
|
||||
onnxoptimizer \
|
||||
multi_quantization \
|
||||
typeguard \
|
||||
numpy \
|
||||
|
@ -56,6 +56,7 @@ RUN pip install --no-cache-dir \
|
||||
onnx \
|
||||
onnxruntime \
|
||||
onnxmltools \
|
||||
onnxoptimizer \
|
||||
multi_quantization \
|
||||
typeguard \
|
||||
numpy \
|
||||
|
@ -56,6 +56,7 @@ RUN pip install --no-cache-dir \
|
||||
onnx \
|
||||
onnxruntime \
|
||||
onnxmltools \
|
||||
onnxoptimizer \
|
||||
multi_quantization \
|
||||
typeguard \
|
||||
numpy \
|
||||
|
@ -56,6 +56,7 @@ RUN pip install --no-cache-dir \
|
||||
onnx \
|
||||
onnxruntime \
|
||||
onnxmltools \
|
||||
onnxoptimizer \
|
||||
multi_quantization \
|
||||
typeguard \
|
||||
numpy \
|
||||
|
@ -56,6 +56,7 @@ RUN pip install --no-cache-dir \
|
||||
onnx \
|
||||
onnxruntime \
|
||||
onnxmltools \
|
||||
onnxoptimizer \
|
||||
multi_quantization \
|
||||
typeguard \
|
||||
numpy \
|
||||
|
@ -56,6 +56,7 @@ RUN pip install --no-cache-dir \
|
||||
onnx \
|
||||
onnxruntime \
|
||||
onnxmltools \
|
||||
onnxoptimizer \
|
||||
multi_quantization \
|
||||
typeguard \
|
||||
numpy \
|
||||
|
@ -38,6 +38,7 @@ from typing import Dict
|
||||
|
||||
import k2
|
||||
import onnx
|
||||
import onnxoptimizer
|
||||
import torch
|
||||
import torch.nn as nn
|
||||
from onnxruntime.quantization import QuantType, quantize_dynamic
|
||||
@ -234,12 +235,13 @@ def export_audio_tagging_model_onnx(
|
||||
|
||||
|
||||
def optimize_model(filename):
|
||||
# see https://github.com/microsoft/onnxruntime/issues/1899#issuecomment-534806537
|
||||
from onnx import optimizer
|
||||
|
||||
# see
|
||||
# https://github.com/microsoft/onnxruntime/issues/1899#issuecomment-534806537
|
||||
# and
|
||||
# https://github.com/onnx/onnx/issues/582#issuecomment-937788108
|
||||
passes = ["extract_constant_to_initializer", "eliminate_unused_initializer"]
|
||||
onnx_model = onnx.load(filename)
|
||||
optimized_model = optimizer.optimize(onnx_model, passes)
|
||||
optimized_model = onnxoptimizer.optimize(onnx_model, passes)
|
||||
onnx.save(optimized_model, filename)
|
||||
|
||||
|
||||
|
@ -8,8 +8,9 @@ pypinyin==0.50.0
|
||||
tensorboard
|
||||
typeguard
|
||||
dill
|
||||
onnx==1.15.0
|
||||
onnxruntime==1.16.3
|
||||
onnx>=1.15.0
|
||||
onnxruntime>=1.16.3
|
||||
onnxoptimizer
|
||||
|
||||
# style check session:
|
||||
black==22.3.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user