optimum
6da9e1ad - Handling ONNX models with external data (#586)

Commit
3 years ago
Handling ONNX models with external data (#586) * attempt at fixing saving onnx model with external data * styling * fix: `cache_dir` wasn't used when loading from transformers * separate onnx_cache_dir argument from model's cache_dir * we can now load large ONNX models by specifying external's data directory * Fix saving external data for large models (seq2seq) * fix saving external data for all ORT models * make style * typing Co-authored-by: Michael Benayoun <mickbenayoun@gmail.com> * apply suggestions * make style * apply suggestion Co-authored-by: Michael Benayoun <mickbenayoun@gmail.com> * export onnx models to separate subfolders when multiple models * this should get us correct file_names but not correct subfolder!! * export_models is only used for multiple submodels * we can now load seq2seq model from local dir (multiple submodels) * fix save_pretrained * * `infer_onnx_filename` now returns a path * refactor `_from_pretrained` * try saving to single file * didn't work, reverting "try saving to single file" This reverts commit 0fdfd873ca6b55db1083365f69f783a7d9d4be49. * add test for seq2seq model with external data * quick fix * try saving to a single file again * Revert "quick fix" This reverts commit 89e64eda59a2b0790087a354e65a468e4d51bee6. * quick fix test * save external data in a single file * save_pretrained now moves model instead of copying from temp directory * Revert "save_pretrained now moves model instead of copying from temp directory" This reverts commit b315f8566591c1acecae1f90652660ff5ac0169f. * add push to hub test * add FORCE_ONNX_EXTERNAL_DATA env and faster test to push to hub * quick fix * we can now save and load large seq2seq models to hub + added test * we no longer save to subfolders, as we use a singla file for external data * make style * apply same fixes to `modeling_decoder.py` * apply same fixes to `modeling_ort.py` * add tests * fix auth token in tests * add **kwargs to all `_save_pretrained` * quick fix * make style * try reducing memory footprint when exporting onnx * replace large seq2seq model with small on to make tests pass * fix merge * we no longer export models to subfolders. instead we regroup external data in a single data file * util from last commit * empty commit * fix import * add onnx utils * fix import2 * better tests * parameterized and skip order Co-authored-by: Michael Benayoun <mickbenayoun@gmail.com> Co-authored-by: Felix Marty <9808326+fxmarty@users.noreply.github.com>
Author
Parents
Loading