Skip to content

Commit

Permalink
Add flag for toggling constant folding. (#1714)
Browse files Browse the repository at this point in the history
  • Loading branch information
monorimet authored Aug 4, 2023
1 parent a5b13fc commit c9de272
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apps/stable_diffusion/src/utils/stable_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions apps/stable_diffusion/src/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit c9de272

Please sign in to comment.