diff --git a/apps/stable_diffusion/src/utils/stable_args.py b/apps/stable_diffusion/src/utils/stable_args.py index c2601fbbd4..202d9047da 100644 --- a/apps/stable_diffusion/src/utils/stable_args.py +++ b/apps/stable_diffusion/src/utils/stable_args.py @@ -519,6 +519,12 @@ def is_valid_file(arg): "in shark importer. Does nothing if import_mlir is false (the default).", ) +p.add_argument( + "--iree_constant_folding", + default=False, + action=argparse.BooleanOptionalAction, + help="Controls constant folding in iree-compile for all SD models.", +) ############################################################################## # Web UI flags diff --git a/apps/stable_diffusion/src/utils/utils.py b/apps/stable_diffusion/src/utils/utils.py index 58a0ff5b83..c7814c6ed5 100644 --- a/apps/stable_diffusion/src/utils/utils.py +++ b/apps/stable_diffusion/src/utils/utils.py @@ -500,6 +500,12 @@ def get_opt_flags(model, precision="fp16"): f"-iree-vulkan-target-triple={args.iree_vulkan_target_triple}" ) + if args.iree_constant_folding == False: + iree_flags.append("--iree-opt-const-expr-hoisting=False") + iree_flags.append( + "--iree-codegen-linalg-max-constant-fold-elements=9223372036854775807" + ) + # Disable bindings fusion to work with moltenVK. if sys.platform == "darwin": iree_flags.append("-iree-stream-fuse-binding=false")