-
Notifications
You must be signed in to change notification settings - Fork 698
[Executorch][target recipes] Add target based recipes for lowering models to a target device #13791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Executorch][target recipes] Add target based recipes for lowering models to a target device #13791
Conversation
…dels to a target device This diff introduces multi backend/ target based recipes to lower a model with very less code. Target recipes provide pre-configured backend recipes to use them and retarget if needed. See RFC: #13732 ## Usage ``` from executorch.export import export, ExportRecipe, IOSTargetRecipeType # CoreML + XNNPACK coreml_xnnpack_recipe = ExportRecipe.get_recipe(IOSTargetRecipeType.IOS_ARM64_COREML_FP32) session = export(model, coreml_xnnpack_recipe, example_inputs) session.save_pte_file("model.pte") ``` ## Advanced usage one can directly use `ExportRecipe.combine_recipes()` to combine specific backend recipes. ``` recipe1 = ExportRecipe.get_recipe(AndroidRecipeType.XYZ) recipe2 = ExportRecipe.get_recipe(XNNPackRecipeType.FP32) combined_recipe = ExportRecipe.combine( [recipe1, recipe2], recipe_name="multi_backend_coreml_xnnpack_fp32" ) session = export(model, combined_recipe, example_inputs) ``` Fixes: #13732 Differential Revision: [D81297451](https://our.internmc.facebook.com/intern/diff/D81297451/) [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/13791
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 New FailuresAs of commit ef5f1ad with merge base 19d22ab ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
…dels to a target device This diff introduces multi backend/ target based recipes to lower a model with very less code. Target recipes provide pre-configured backend recipes to use them and retarget if needed. See RFC: #13732 ## Usage ``` from executorch.export import export, ExportRecipe, IOSTargetRecipeType # CoreML + XNNPACK coreml_xnnpack_recipe = ExportRecipe.get_recipe(IOSTargetRecipeType.IOS_ARM64_COREML_FP32) session = export(model, coreml_xnnpack_recipe, example_inputs) session.save_pte_file("model.pte") ``` ## Advanced usage one can directly use `ExportRecipe.combine_recipes()` to combine specific backend recipes. ``` recipe1 = ExportRecipe.get_recipe(AndroidRecipeType.XYZ) recipe2 = ExportRecipe.get_recipe(XNNPackRecipeType.FP32) combined_recipe = ExportRecipe.combine( [recipe1, recipe2], recipe_name="multi_backend_coreml_xnnpack_fp32" ) session = export(model, combined_recipe, example_inputs) ``` Fixes: #13732 Differential Revision: [D81297451](https://our.internmc.facebook.com/intern/diff/D81297451/) ghstack-source-id: 306434236 Pull Request resolved: #13791
|
This pull request was exported from Phabricator. Differential Revision: D81297451 |
This PR needs a
|
…lowering models to a target device" This diff introduces multi backend/ target based recipes to lower a model with very less code. Target recipes provide pre-configured backend recipes to use them and retarget if needed. See RFC: #13732 ## Usage ``` from executorch.export import export, ExportRecipe, IOSTargetRecipeType # CoreML + XNNPACK coreml_xnnpack_recipe = ExportRecipe.get_recipe(IOSTargetRecipeType.IOS_ARM64_COREML_FP32) session = export(model, coreml_xnnpack_recipe, example_inputs) session.save_pte_file("model.pte") ``` ## Advanced usage one can directly use `ExportRecipe.combine_recipes()` to combine specific backend recipes. ``` recipe1 = ExportRecipe.get_recipe(AndroidRecipeType.XYZ) recipe2 = ExportRecipe.get_recipe(XNNPackRecipeType.FP32) combined_recipe = ExportRecipe.combine( [recipe1, recipe2], recipe_name="multi_backend_coreml_xnnpack_fp32" ) session = export(model, combined_recipe, example_inputs) ``` Fixes: #13732 Differential Revision: [D81297451](https://our.internmc.facebook.com/intern/diff/D81297451/) [ghstack-poisoned]
…dels to a target device Pull Request resolved: #13791 This diff introduces multi backend/ target based recipes to lower a model with very less code. Target recipes provide pre-configured backend recipes to use them and retarget if needed. See RFC: #13732 ## Usage ``` from executorch.export import export, ExportRecipe, IOSTargetRecipeType # CoreML + XNNPACK coreml_xnnpack_recipe = ExportRecipe.get_recipe(IOSTargetRecipeType.IOS_ARM64_COREML_FP32) session = export(model, coreml_xnnpack_recipe, example_inputs) session.save_pte_file("model.pte") ``` ## Advanced usage one can directly use `ExportRecipe.combine_recipes()` to combine specific backend recipes. ``` recipe1 = ExportRecipe.get_recipe(AndroidRecipeType.XYZ) recipe2 = ExportRecipe.get_recipe(XNNPackRecipeType.FP32) combined_recipe = ExportRecipe.combine( [recipe1, recipe2], recipe_name="multi_backend_coreml_xnnpack_fp32" ) session = export(model, combined_recipe, example_inputs) ``` Fixes: #13732 ghstack-source-id: 306438497 @exported-using-ghexport Differential Revision: [D81297451](https://our.internmc.facebook.com/intern/diff/D81297451/)
|
This pull request was exported from Phabricator. Differential Revision: D81297451 |
|
I left a comment on the original issue. Not fully convinced why we need multibackend recipe as a separate concept |
…lowering models to a target device" This diff introduces multi backend/ target based recipes to lower a model with very less code. Target recipes provide pre-configured backend recipes to use them and retarget if needed. See RFC: #13732 ## Usage ``` from executorch.export import export, ExportRecipe, IOSTargetRecipeType # CoreML + XNNPACK coreml_xnnpack_recipe = ExportRecipe.get_recipe(IOSTargetRecipeType.IOS_ARM64_COREML_FP32) session = export(model, coreml_xnnpack_recipe, example_inputs) session.save_pte_file("model.pte") ``` ## Advanced usage one can directly use `ExportRecipe.combine_recipes()` to combine specific backend recipes. ``` recipe1 = ExportRecipe.get_recipe(AndroidRecipeType.XYZ) recipe2 = ExportRecipe.get_recipe(XNNPackRecipeType.FP32) combined_recipe = ExportRecipe.combine( [recipe1, recipe2], recipe_name="multi_backend_coreml_xnnpack_fp32" ) session = export(model, combined_recipe, example_inputs) ``` Fixes: #13732 Differential Revision: [D81297451](https://our.internmc.facebook.com/intern/diff/D81297451/) [ghstack-poisoned]
…dels to a target device Pull Request resolved: #13791 This diff introduces multi backend/ target based recipes to lower a model with very less code. Target recipes provide pre-configured backend recipes to use them and retarget if needed. See RFC: #13732 ## Usage ``` from executorch.export import export from executorch.export.target_recipes import get_ios_recipe # CoreML + XNNPACK (FP32) recipe = get_ios_recipe() # default = "ios-arm64-coreml-fp32" session = export(model, recipe, example_inputs) session.save_pte_file("model.pte") ``` ## Advanced usage to combine specific recipes of two or one backend one can directly use `ExportRecipe.combine_recipes()` to combine specific backend recipes. ``` recipe1 = ExportRecipe.get_recipe(CoreMLRecipeType.FP32) recipe2 = ExportRecipe.get_recipe(XNNPackRecipeType.FP32) combined_recipe = ExportRecipe.combine( [recipe1, recipe2], recipe_name="multi_backend_coreml_xnnpack_fp32" ) session = export(model, combined_recipe, example_inputs) ``` Fixes: #13732 ghstack-source-id: 307058764 @exported-using-ghexport Differential Revision: [D81297451](https://our.internmc.facebook.com/intern/diff/D81297451/)
|
This pull request was exported from Phabricator. Differential Revision: D81297451 |
…lowering models to a target device" This diff introduces multi backend/ target based recipes to lower a model with very less code. Target recipes provide pre-configured backend recipes to use them and retarget if needed. See RFC: #13732 ## Usage ``` from executorch.export import export, ExportRecipe, IOSTargetRecipeType # CoreML + XNNPACK coreml_xnnpack_recipe = ExportRecipe.get_recipe(IOSTargetRecipeType.IOS_ARM64_COREML_FP32) session = export(model, coreml_xnnpack_recipe, example_inputs) session.save_pte_file("model.pte") ``` ## Advanced usage one can directly use `ExportRecipe.combine_recipes()` to combine specific backend recipes. ``` recipe1 = ExportRecipe.get_recipe(AndroidRecipeType.XYZ) recipe2 = ExportRecipe.get_recipe(XNNPackRecipeType.FP32) combined_recipe = ExportRecipe.combine( [recipe1, recipe2], recipe_name="multi_backend_coreml_xnnpack_fp32" ) session = export(model, combined_recipe, example_inputs) ``` Fixes: #13732 Differential Revision: [D81297451](https://our.internmc.facebook.com/intern/diff/D81297451/) [ghstack-poisoned]
…dels to a target device Pull Request resolved: #13791 This diff introduces multi backend/ target based recipes to lower a model with very less code. Target recipes provide pre-configured backend recipes to use them and retarget if needed. See RFC: #13732 ## Usage ``` from executorch.export import export from executorch.export.target_recipes import get_ios_recipe # CoreML + XNNPACK (FP32) recipe = get_ios_recipe() # default = "ios-arm64-coreml-fp32" session = export(model, recipe, example_inputs) session.save_pte_file("model.pte") ``` ## Advanced usage to combine specific recipes of one or two or backends one can directly use `ExportRecipe.combine_recipes()` to combine specific backend recipes. ``` recipe1 = ExportRecipe.get_recipe(CoreMLRecipeType.FP32) recipe2 = ExportRecipe.get_recipe(XNNPackRecipeType.FP32) combined_recipe = ExportRecipe.combine( [recipe1, recipe2], recipe_name="multi_backend_coreml_xnnpack_fp32" ) session = export(model, combined_recipe, example_inputs) ``` Additional changes: 1. Relaxed kwarg validation in the backend providers to just ignore them instead of erroring out. Fixes: #13732 ghstack-source-id: 307121550 @exported-using-ghexport Differential Revision: [D81297451](https://our.internmc.facebook.com/intern/diff/D81297451/)
|
This pull request was exported from Phabricator. Differential Revision: D81297451 |
@kimishpatel Removed the multi backend provider and went with simple funciton calls. |
…lowering models to a target device" This diff introduces multi backend/ target based recipes to lower a model with very less code. Target recipes provide pre-configured backend recipes to use them and retarget if needed. See RFC: #13732 ## Usage ``` from executorch.export import export, ExportRecipe, IOSTargetRecipeType # CoreML + XNNPACK coreml_xnnpack_recipe = ExportRecipe.get_recipe(IOSTargetRecipeType.IOS_ARM64_COREML_FP32) session = export(model, coreml_xnnpack_recipe, example_inputs) session.save_pte_file("model.pte") ``` ## Advanced usage one can directly use `ExportRecipe.combine_recipes()` to combine specific backend recipes. ``` recipe1 = ExportRecipe.get_recipe(AndroidRecipeType.XYZ) recipe2 = ExportRecipe.get_recipe(XNNPackRecipeType.FP32) combined_recipe = ExportRecipe.combine( [recipe1, recipe2], recipe_name="multi_backend_coreml_xnnpack_fp32" ) session = export(model, combined_recipe, example_inputs) ``` Fixes: #13732 Differential Revision: [D81297451](https://our.internmc.facebook.com/intern/diff/D81297451/) [ghstack-poisoned]
…dels to a target device Pull Request resolved: #13791 This diff introduces multi backend/ target based recipes to lower a model with very less code. Target recipes provide pre-configured backend recipes to use them and retarget if needed. See RFC: #13732 ## Usage ``` from executorch.export import export from executorch.export.target_recipes import get_ios_recipe # CoreML + XNNPACK (FP32) recipe = get_ios_recipe() # default = "ios-arm64-coreml-fp32" session = export(model, recipe, example_inputs) session.save_pte_file("model.pte") ``` ## Advanced usage to combine specific recipes of one or two or backends one can directly use `ExportRecipe.combine_recipes()` to combine specific backend recipes. ``` recipe1 = ExportRecipe.get_recipe(CoreMLRecipeType.FP32) recipe2 = ExportRecipe.get_recipe(XNNPackRecipeType.FP32) combined_recipe = ExportRecipe.combine( [recipe1, recipe2], recipe_name="multi_backend_coreml_xnnpack_fp32" ) session = export(model, combined_recipe, example_inputs) ``` Additional changes: 1. Relaxed kwarg validation in the backend providers to just ignore them instead of erroring out. Fixes: #13732 ghstack-source-id: 307139141 @exported-using-ghexport Differential Revision: [D81297451](https://our.internmc.facebook.com/intern/diff/D81297451/)
|
This pull request was exported from Phabricator. Differential Revision: D81297451 |
| if unexpected: | ||
| raise ValueError( | ||
| f"Recipe '{recipe_type.value}' received unexpected parameters: {list(unexpected)}" | ||
| logging.warning( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this turned into warning now? to combine multiple recipes? and fallback to the other backend when it fails?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, to combine multiple recipes, for example, get_coreml_recipe(**kwargs) this will have to forward them to both coreml and xnnpack. Hard failure like above would restrict the creation of multi backend recipes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks ok to me. some nits plus a comment on quantizaiton.
you probably want to add recipes plus test for android
Thanks for the review, will add android specific things after adding QNN recipes, which i'm working on right now. |
…lowering models to a target device" This diff introduces multi backend/ target based recipes to lower a model with very less code. Target recipes provide pre-configured backend recipes to use them and retarget if needed. See RFC: #13732 ## Usage ``` from executorch.export import export, ExportRecipe, IOSTargetRecipeType # CoreML + XNNPACK coreml_xnnpack_recipe = ExportRecipe.get_recipe(IOSTargetRecipeType.IOS_ARM64_COREML_FP32) session = export(model, coreml_xnnpack_recipe, example_inputs) session.save_pte_file("model.pte") ``` ## Advanced usage one can directly use `ExportRecipe.combine_recipes()` to combine specific backend recipes. ``` recipe1 = ExportRecipe.get_recipe(AndroidRecipeType.XYZ) recipe2 = ExportRecipe.get_recipe(XNNPackRecipeType.FP32) combined_recipe = ExportRecipe.combine( [recipe1, recipe2], recipe_name="multi_backend_coreml_xnnpack_fp32" ) session = export(model, combined_recipe, example_inputs) ``` Fixes: #13732 Differential Revision: [D81297451](https://our.internmc.facebook.com/intern/diff/D81297451/) [ghstack-poisoned]
…dels to a target device Pull Request resolved: #13791 This diff introduces multi backend/ target based recipes to lower a model with very less code. Target recipes provide pre-configured backend recipes to use them and retarget if needed. See RFC: #13732 ## Usage ``` from executorch.export import export from executorch.export.target_recipes import get_ios_recipe # CoreML + XNNPACK (FP32) recipe = get_ios_recipe() # default = "ios-arm64-coreml-fp32" session = export(model, recipe, example_inputs) session.save_pte_file("model.pte") ``` ## Advanced usage to combine specific recipes of one or two or backends one can directly use `ExportRecipe.combine_recipes()` to combine specific backend recipes. ``` recipe1 = ExportRecipe.get_recipe(CoreMLRecipeType.FP32) recipe2 = ExportRecipe.get_recipe(XNNPackRecipeType.FP32) combined_recipe = ExportRecipe.combine( [recipe1, recipe2], recipe_name="multi_backend_coreml_xnnpack_fp32" ) session = export(model, combined_recipe, example_inputs) ``` Additional changes: 1. Relaxed kwarg validation in the backend providers to just ignore them instead of erroring out. Fixes: #13732 ghstack-source-id: 307321089 @exported-using-ghexport Differential Revision: [D81297451](https://our.internmc.facebook.com/intern/diff/D81297451/)
|
This pull request was exported from Phabricator. Differential Revision: D81297451 |
…lowering models to a target device" This diff introduces multi backend/ target based recipes to lower a model with very less code. Target recipes provide pre-configured backend recipes to use them and retarget if needed. See RFC: #13732 ## Usage ``` from executorch.export import export from executorch.export.target_recipes import get_ios_recipe # CoreML + XNNPACK (FP32) recipe = get_ios_recipe() # default = "ios-arm64-coreml-fp16" session = export(model, recipe, example_inputs) session.save_pte_file("model.pte") ``` ## Advanced usage to combine specific recipes of one or two or backends one can directly use `ExportRecipe.combine_recipes()` to combine specific backend recipes. ``` recipe1 = ExportRecipe.get_recipe(CoreMLRecipeType.FP32) recipe2 = ExportRecipe.get_recipe(XNNPackRecipeType.FP32) combined_recipe = ExportRecipe.combine( [recipe1, recipe2], recipe_name="multi_backend_coreml_xnnpack_fp32" ) session = export(model, combined_recipe, example_inputs) ``` Additional changes: 1. Relaxed kwarg validation in the backend providers to just ignore them instead of erroring out. Fixes: #13732 Differential Revision: [D81297451](https://our.internmc.facebook.com/intern/diff/D81297451/) [ghstack-poisoned]
…dels to a target device Pull Request resolved: #13791 This diff introduces multi backend/ target based recipes to lower a model with very less code. Target recipes provide pre-configured backend recipes to use them and retarget if needed. See RFC: #13732 ## Usage ``` from executorch.export import export from executorch.export.target_recipes import get_ios_recipe # CoreML + XNNPACK (FP32) recipe = get_ios_recipe() # default = "ios-arm64-coreml-fp16" session = export(model, recipe, example_inputs) session.save_pte_file("model.pte") ``` ## Advanced usage to combine specific recipes of one or two or backends one can directly use `ExportRecipe.combine_recipes()` to combine specific backend recipes. ``` recipe1 = ExportRecipe.get_recipe(CoreMLRecipeType.FP32) recipe2 = ExportRecipe.get_recipe(XNNPackRecipeType.FP32) combined_recipe = ExportRecipe.combine( [recipe1, recipe2], recipe_name="multi_backend_coreml_xnnpack_fp32" ) session = export(model, combined_recipe, example_inputs) ``` Additional changes: 1. Relaxed kwarg validation in the backend providers to just ignore them instead of erroring out. Fixes: #13732 ghstack-source-id: 307327146 @exported-using-ghexport Differential Revision: [D81297451](https://our.internmc.facebook.com/intern/diff/D81297451/)
|
This pull request was exported from Phabricator. Differential Revision: D81297451 |
…lowering models to a target device" This diff introduces multi backend/ target based recipes to lower a model with very less code. Target recipes provide pre-configured backend recipes to use them and retarget if needed. See RFC: #13732 ## Usage ``` from executorch.export import export from executorch.export.target_recipes import get_ios_recipe # CoreML + XNNPACK (FP32) recipe = get_ios_recipe() # default = "ios-arm64-coreml-fp16" session = export(model, recipe, example_inputs) session.save_pte_file("model.pte") ``` ## Advanced usage to combine specific recipes of one or two or backends one can directly use `ExportRecipe.combine_recipes()` to combine specific backend recipes. ``` recipe1 = ExportRecipe.get_recipe(CoreMLRecipeType.FP32) recipe2 = ExportRecipe.get_recipe(XNNPackRecipeType.FP32) combined_recipe = ExportRecipe.combine( [recipe1, recipe2], recipe_name="multi_backend_coreml_xnnpack_fp32" ) session = export(model, combined_recipe, example_inputs) ``` Additional changes: 1. Relaxed kwarg validation in the backend providers to just ignore them instead of erroring out. Fixes: #13732 Differential Revision: [D81297451](https://our.internmc.facebook.com/intern/diff/D81297451/) [ghstack-poisoned]
…dels to a target device Pull Request resolved: #13791 This diff introduces multi backend/ target based recipes to lower a model with very less code. Target recipes provide pre-configured backend recipes to use them and retarget if needed. See RFC: #13732 ## Usage ``` from executorch.export import export from executorch.export.target_recipes import get_ios_recipe # CoreML + XNNPACK (FP32) recipe = get_ios_recipe() # default = "ios-arm64-coreml-fp16" session = export(model, recipe, example_inputs) session.save_pte_file("model.pte") ``` ## Advanced usage to combine specific recipes of one or two or backends one can directly use `ExportRecipe.combine_recipes()` to combine specific backend recipes. ``` recipe1 = ExportRecipe.get_recipe(CoreMLRecipeType.FP32) recipe2 = ExportRecipe.get_recipe(XNNPackRecipeType.FP32) combined_recipe = ExportRecipe.combine( [recipe1, recipe2], recipe_name="multi_backend_coreml_xnnpack_fp32" ) session = export(model, combined_recipe, example_inputs) ``` Additional changes: 1. Relaxed kwarg validation in the backend providers to just ignore them instead of erroring out. Fixes: #13732 ghstack-source-id: 307388517 @exported-using-ghexport Differential Revision: [D81297451](https://our.internmc.facebook.com/intern/diff/D81297451/)
|
This pull request was exported from Phabricator. Differential Revision: D81297451 |
…lowering models to a target device" This diff introduces multi backend/ target based recipes to lower a model with very less code. Target recipes provide pre-configured backend recipes to use them and retarget if needed. See RFC: #13732 ## Usage ``` from executorch.export import export from executorch.export.target_recipes import get_ios_recipe # CoreML + XNNPACK (FP32) recipe = get_ios_recipe() # default = "ios-arm64-coreml-fp16" session = export(model, recipe, example_inputs) session.save_pte_file("model.pte") ``` ## Advanced usage to combine specific recipes of one or two or backends one can directly use `ExportRecipe.combine_recipes()` to combine specific backend recipes. ``` recipe1 = ExportRecipe.get_recipe(CoreMLRecipeType.FP32) recipe2 = ExportRecipe.get_recipe(XNNPackRecipeType.FP32) combined_recipe = ExportRecipe.combine( [recipe1, recipe2], recipe_name="multi_backend_coreml_xnnpack_fp32" ) session = export(model, combined_recipe, example_inputs) ``` Additional changes: 1. Relaxed kwarg validation in the backend providers to just ignore them instead of erroring out. Fixes: #13732 Differential Revision: [D81297451](https://our.internmc.facebook.com/intern/diff/D81297451/) [ghstack-poisoned]
…dels to a target device Pull Request resolved: #13791 This diff introduces multi backend/ target based recipes to lower a model with very less code. Target recipes provide pre-configured backend recipes to use them and retarget if needed. See RFC: #13732 ## Usage ``` from executorch.export import export from executorch.export.target_recipes import get_ios_recipe # CoreML + XNNPACK (FP32) recipe = get_ios_recipe() # default = "ios-arm64-coreml-fp16" session = export(model, recipe, example_inputs) session.save_pte_file("model.pte") ``` ## Advanced usage to combine specific recipes of one or two or backends one can directly use `ExportRecipe.combine_recipes()` to combine specific backend recipes. ``` recipe1 = ExportRecipe.get_recipe(CoreMLRecipeType.FP32) recipe2 = ExportRecipe.get_recipe(XNNPackRecipeType.FP32) combined_recipe = ExportRecipe.combine( [recipe1, recipe2], recipe_name="multi_backend_coreml_xnnpack_fp32" ) session = export(model, combined_recipe, example_inputs) ``` Additional changes: 1. Relaxed kwarg validation in the backend providers to just ignore them instead of erroring out. Fixes: #13732 ghstack-source-id: 307424597 @exported-using-ghexport Differential Revision: [D81297451](https://our.internmc.facebook.com/intern/diff/D81297451/)
|
This pull request was exported from Phabricator. Differential Revision: D81297451 |
…lowering models to a target device" This diff introduces multi backend/ target based recipes to lower a model with very less code. Target recipes provide pre-configured backend recipes to use them and retarget if needed. See RFC: #13732 ## Usage ``` from executorch.export import export from executorch.export.target_recipes import get_ios_recipe # CoreML + XNNPACK (FP32) recipe = get_ios_recipe() # default = "ios-arm64-coreml-fp16" session = export(model, recipe, example_inputs) session.save_pte_file("model.pte") ``` ## Advanced usage to combine specific recipes of one or two or backends one can directly use `ExportRecipe.combine_recipes()` to combine specific backend recipes. ``` recipe1 = ExportRecipe.get_recipe(CoreMLRecipeType.FP32) recipe2 = ExportRecipe.get_recipe(XNNPackRecipeType.FP32) combined_recipe = ExportRecipe.combine( [recipe1, recipe2], recipe_name="multi_backend_coreml_xnnpack_fp32" ) session = export(model, combined_recipe, example_inputs) ``` Additional changes: 1. Relaxed kwarg validation in the backend providers to just ignore them instead of erroring out. Fixes: #13732 Differential Revision: [D81297451](https://our.internmc.facebook.com/intern/diff/D81297451/) [ghstack-poisoned]
…dels to a target device Pull Request resolved: #13791 This diff introduces multi backend/ target based recipes to lower a model with very less code. Target recipes provide pre-configured backend recipes to use them and retarget if needed. See RFC: #13732 ## Usage ``` from executorch.export import export from executorch.export.target_recipes import get_ios_recipe # CoreML + XNNPACK (FP32) recipe = get_ios_recipe() # default = "ios-arm64-coreml-fp16" session = export(model, recipe, example_inputs) session.save_pte_file("model.pte") ``` ## Advanced usage to combine specific recipes of one or two or backends one can directly use `ExportRecipe.combine_recipes()` to combine specific backend recipes. ``` recipe1 = ExportRecipe.get_recipe(CoreMLRecipeType.FP32) recipe2 = ExportRecipe.get_recipe(XNNPackRecipeType.FP32) combined_recipe = ExportRecipe.combine( [recipe1, recipe2], recipe_name="multi_backend_coreml_xnnpack_fp32" ) session = export(model, combined_recipe, example_inputs) ``` Additional changes: 1. Relaxed kwarg validation in the backend providers to just ignore them instead of erroring out. Fixes: #13732 ghstack-source-id: 307671542 @exported-using-ghexport Differential Revision: [D81297451](https://our.internmc.facebook.com/intern/diff/D81297451/)
|
This pull request was exported from Phabricator. Differential Revision: D81297451 |
e4bf93e
into
gh/abhinaykukkadapu/8/base
…dels to a target device Pull Request resolved: #13791 This diff introduces multi backend/ target based recipes to lower a model with very less code. Target recipes provide pre-configured backend recipes to use them and retarget if needed. See RFC: #13732 ## Usage ``` from executorch.export import export from executorch.export.target_recipes import get_ios_recipe # CoreML + XNNPACK (FP32) recipe = get_ios_recipe() # default = "ios-arm64-coreml-fp16" session = export(model, recipe, example_inputs) session.save_pte_file("model.pte") ``` ## Advanced usage to combine specific recipes of one or two or backends one can directly use `ExportRecipe.combine_recipes()` to combine specific backend recipes. ``` recipe1 = ExportRecipe.get_recipe(CoreMLRecipeType.FP32) recipe2 = ExportRecipe.get_recipe(XNNPackRecipeType.FP32) combined_recipe = ExportRecipe.combine( [recipe1, recipe2], recipe_name="multi_backend_coreml_xnnpack_fp32" ) session = export(model, combined_recipe, example_inputs) ``` Additional changes: 1. Relaxed kwarg validation in the backend providers to just ignore them instead of erroring out. Fixes: #13732 ghstack-source-id: 307671542 @exported-using-ghexport Differential Revision: [D81297451](https://our.internmc.facebook.com/intern/diff/D81297451/)
Stack from ghstack (oldest at bottom):
This diff introduces multi backend/ target based recipes to lower a model with very less code. Target recipes provide pre-configured backend recipes to use them and retarget if needed.
See RFC: #13732
Usage
Advanced usage to combine specific recipes of one or two or backends
one can directly use
ExportRecipe.combine_recipes()to combine specific backend recipes.Additional changes:
Fixes: #13732
Differential Revision: D81297451