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
|
set -ex
|
||||||
|
|
||||||
|
python3 -m pip install onnxoptimizer
|
||||||
|
|
||||||
log() {
|
log() {
|
||||||
# This function is from espnet
|
# This function is from espnet
|
||||||
local fname=${BASH_SOURCE[1]##*/}
|
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 \
|
multi_quantization \
|
||||||
numba \
|
numba \
|
||||||
numpy \
|
numpy \
|
||||||
|
onnxoptimizer \
|
||||||
onnx \
|
onnx \
|
||||||
onnxmltools \
|
onnxmltools \
|
||||||
onnxruntime \
|
onnxruntime \
|
||||||
|
@ -55,6 +55,7 @@ RUN pip install --no-cache-dir \
|
|||||||
onnx \
|
onnx \
|
||||||
onnxruntime \
|
onnxruntime \
|
||||||
onnxmltools \
|
onnxmltools \
|
||||||
|
onnxoptimizer \
|
||||||
multi_quantization \
|
multi_quantization \
|
||||||
typeguard \
|
typeguard \
|
||||||
numpy \
|
numpy \
|
||||||
|
@ -55,6 +55,7 @@ RUN pip install --no-cache-dir \
|
|||||||
onnx \
|
onnx \
|
||||||
onnxruntime \
|
onnxruntime \
|
||||||
onnxmltools \
|
onnxmltools \
|
||||||
|
onnxoptimizer \
|
||||||
multi_quantization \
|
multi_quantization \
|
||||||
typeguard \
|
typeguard \
|
||||||
numpy \
|
numpy \
|
||||||
|
@ -69,6 +69,7 @@ RUN pip uninstall -y tqdm && \
|
|||||||
onnx \
|
onnx \
|
||||||
onnxruntime \
|
onnxruntime \
|
||||||
onnxmltools \
|
onnxmltools \
|
||||||
|
onnxoptimizer \
|
||||||
multi_quantization \
|
multi_quantization \
|
||||||
typeguard \
|
typeguard \
|
||||||
numpy \
|
numpy \
|
||||||
|
@ -56,6 +56,7 @@ RUN pip install --no-cache-dir \
|
|||||||
onnx \
|
onnx \
|
||||||
onnxruntime \
|
onnxruntime \
|
||||||
onnxmltools \
|
onnxmltools \
|
||||||
|
onnxoptimizer \
|
||||||
multi_quantization \
|
multi_quantization \
|
||||||
typeguard \
|
typeguard \
|
||||||
numpy \
|
numpy \
|
||||||
|
@ -56,6 +56,7 @@ RUN pip install --no-cache-dir \
|
|||||||
onnx \
|
onnx \
|
||||||
onnxruntime \
|
onnxruntime \
|
||||||
onnxmltools \
|
onnxmltools \
|
||||||
|
onnxoptimizer \
|
||||||
multi_quantization \
|
multi_quantization \
|
||||||
typeguard \
|
typeguard \
|
||||||
numpy \
|
numpy \
|
||||||
|
@ -56,6 +56,7 @@ RUN pip install --no-cache-dir \
|
|||||||
onnx \
|
onnx \
|
||||||
onnxruntime \
|
onnxruntime \
|
||||||
onnxmltools \
|
onnxmltools \
|
||||||
|
onnxoptimizer \
|
||||||
multi_quantization \
|
multi_quantization \
|
||||||
typeguard \
|
typeguard \
|
||||||
numpy \
|
numpy \
|
||||||
|
@ -56,6 +56,7 @@ RUN pip install --no-cache-dir \
|
|||||||
onnx \
|
onnx \
|
||||||
onnxruntime \
|
onnxruntime \
|
||||||
onnxmltools \
|
onnxmltools \
|
||||||
|
onnxoptimizer \
|
||||||
multi_quantization \
|
multi_quantization \
|
||||||
typeguard \
|
typeguard \
|
||||||
numpy \
|
numpy \
|
||||||
|
@ -56,6 +56,7 @@ RUN pip install --no-cache-dir \
|
|||||||
onnx \
|
onnx \
|
||||||
onnxruntime \
|
onnxruntime \
|
||||||
onnxmltools \
|
onnxmltools \
|
||||||
|
onnxoptimizer \
|
||||||
multi_quantization \
|
multi_quantization \
|
||||||
typeguard \
|
typeguard \
|
||||||
numpy \
|
numpy \
|
||||||
|
@ -56,6 +56,7 @@ RUN pip install --no-cache-dir \
|
|||||||
onnx \
|
onnx \
|
||||||
onnxruntime \
|
onnxruntime \
|
||||||
onnxmltools \
|
onnxmltools \
|
||||||
|
onnxoptimizer \
|
||||||
multi_quantization \
|
multi_quantization \
|
||||||
typeguard \
|
typeguard \
|
||||||
numpy \
|
numpy \
|
||||||
|
@ -56,6 +56,7 @@ RUN pip install --no-cache-dir \
|
|||||||
onnx \
|
onnx \
|
||||||
onnxruntime \
|
onnxruntime \
|
||||||
onnxmltools \
|
onnxmltools \
|
||||||
|
onnxoptimizer \
|
||||||
multi_quantization \
|
multi_quantization \
|
||||||
typeguard \
|
typeguard \
|
||||||
numpy \
|
numpy \
|
||||||
|
@ -56,6 +56,7 @@ RUN pip install --no-cache-dir \
|
|||||||
onnx \
|
onnx \
|
||||||
onnxruntime \
|
onnxruntime \
|
||||||
onnxmltools \
|
onnxmltools \
|
||||||
|
onnxoptimizer \
|
||||||
multi_quantization \
|
multi_quantization \
|
||||||
typeguard \
|
typeguard \
|
||||||
numpy \
|
numpy \
|
||||||
|
@ -56,6 +56,7 @@ RUN pip install --no-cache-dir \
|
|||||||
onnx \
|
onnx \
|
||||||
onnxruntime \
|
onnxruntime \
|
||||||
onnxmltools \
|
onnxmltools \
|
||||||
|
onnxoptimizer \
|
||||||
multi_quantization \
|
multi_quantization \
|
||||||
typeguard \
|
typeguard \
|
||||||
numpy \
|
numpy \
|
||||||
|
@ -38,6 +38,7 @@ from typing import Dict
|
|||||||
|
|
||||||
import k2
|
import k2
|
||||||
import onnx
|
import onnx
|
||||||
|
import onnxoptimizer
|
||||||
import torch
|
import torch
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
from onnxruntime.quantization import QuantType, quantize_dynamic
|
from onnxruntime.quantization import QuantType, quantize_dynamic
|
||||||
@ -234,12 +235,13 @@ def export_audio_tagging_model_onnx(
|
|||||||
|
|
||||||
|
|
||||||
def optimize_model(filename):
|
def optimize_model(filename):
|
||||||
# see https://github.com/microsoft/onnxruntime/issues/1899#issuecomment-534806537
|
# see
|
||||||
from onnx import optimizer
|
# 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"]
|
passes = ["extract_constant_to_initializer", "eliminate_unused_initializer"]
|
||||||
onnx_model = onnx.load(filename)
|
onnx_model = onnx.load(filename)
|
||||||
optimized_model = optimizer.optimize(onnx_model, passes)
|
optimized_model = onnxoptimizer.optimize(onnx_model, passes)
|
||||||
onnx.save(optimized_model, filename)
|
onnx.save(optimized_model, filename)
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,8 +8,9 @@ pypinyin==0.50.0
|
|||||||
tensorboard
|
tensorboard
|
||||||
typeguard
|
typeguard
|
||||||
dill
|
dill
|
||||||
onnx==1.15.0
|
onnx>=1.15.0
|
||||||
onnxruntime==1.16.3
|
onnxruntime>=1.16.3
|
||||||
|
onnxoptimizer
|
||||||
|
|
||||||
# style check session:
|
# style check session:
|
||||||
black==22.3.0
|
black==22.3.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user