m2m模型翻译
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.1 KiB

6 months ago
  1. #!/usr/bin/env python3
  2. # Copyright (c) Microsoft Corporation. All rights reserved.
  3. # Licensed under the MIT License.
  4. import argparse
  5. import os
  6. import pathlib
  7. import onnx
  8. from .qdq_model_utils import fix_dq_nodes_with_multiple_consumers
  9. def optimize_qdq_model():
  10. parser = argparse.ArgumentParser(
  11. os.path.basename(__file__),
  12. description="""
  13. Update a QDQ format ONNX model to ensure optimal performance when executed using
  14. ONNX Runtime.
  15. """,
  16. )
  17. parser.add_argument("input_model", type=pathlib.Path, help="Provide path to ONNX model to update.")
  18. parser.add_argument("output_model", type=pathlib.Path, help="Provide path to write updated ONNX model to.")
  19. args = parser.parse_args()
  20. model = onnx.load(str(args.input_model.resolve(strict=True)))
  21. # there's just one utility to run currently but we expect that will grow
  22. fix_dq_nodes_with_multiple_consumers(model)
  23. onnx.save(model, str(args.output_model.resolve()))
  24. if __name__ == "__main__":
  25. optimize_qdq_model()