pesi
/

Luigi commited on
Commit
f9a6075
1 Parent(s): e8f08e3

Re-quantize models in FP16 in keep positional encoding in FP32 to avoid bad accuracy

Browse files
convert_to_fp16.py CHANGED
@@ -2,6 +2,8 @@ import argparse
2
  from onnxmltools.utils.float16_converter import convert_float_to_float16
3
  from onnxmltools.utils import load_model, save_model
4
 
 
 
5
  def main():
6
  # Set up an argument parser
7
  parser = argparse.ArgumentParser(description='Convert ONNX model from Float32 to Float16.')
@@ -17,7 +19,7 @@ def main():
17
 
18
  # Convert model from Float32 to Float16
19
  print("Converting model...")
20
- new_onnx_model = convert_float_to_float16(onnx_model, min_positive_val=1e-7, max_finite_val=1e4, keep_io_types=True)
21
 
22
  # Save the converted model
23
  print(f"Saving converted model to {args.output_model}")
 
2
  from onnxmltools.utils.float16_converter import convert_float_to_float16
3
  from onnxmltools.utils import load_model, save_model
4
 
5
+ node_block_list = ['Sin_689', 'MatMul_694', 'MatMul_698', 'Clip_699', 'Clip_700', 'Sub_702', 'Sub_704']
6
+
7
  def main():
8
  # Set up an argument parser
9
  parser = argparse.ArgumentParser(description='Convert ONNX model from Float32 to Float16.')
 
19
 
20
  # Convert model from Float32 to Float16
21
  print("Converting model...")
22
+ new_onnx_model = convert_float_to_float16(onnx_model, min_positive_val=1e-7, max_finite_val=1e4, keep_io_types=True, node_block_list=node_block_list)
23
 
24
  # Save the converted model
25
  print(f"Saving converted model to {args.output_model}")
rtmo-l.fp16.onnx CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:955c0c6566c46b8c720cdd822bda8d647827fa7d76e89371cc7f287e392a72ed
3
- size 88025438
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:94010d0d62a79c87e7dd3fdf74395f6ed4e73918e4fc8ee3de94d90051dcc160
3
+ size 88025578
rtmo-m.fp16.onnx CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:908b45cc80feb94e9abbfc1c3254db53da1c4853a8e70e2985c5d10d1a06cf74
3
- size 44703294
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0413fa25c7796c3f1ed97ee92069192a5e923a7422aedb2291bcab96042ee184
3
+ size 44703434
rtmo-s.fp16.onnx CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:25c5f673bb64853f01f3b77c87a85d51dd85f53f95ddd11fbcf635166e0e0391
3
- size 19869781
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5ff4fd6f14d9f5c7fe4b59896789debc5713a39f64f7ecf60bbb98ae59c75509
3
+ size 19873230
rtmo-t.fp16.onnx CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:227a75f6b5b954f05cf595d2171013b97a1b885c512985590d077ff599502cd6
3
- size 13731720
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a4d4df491a850429f32e738ec3273aceecda9e08e034607e9ea2413270977b66
3
+ size 13735169