Skip to content

Commit

Permalink
update checker
Browse files Browse the repository at this point in the history
  • Loading branch information
JingyaHuang committed Aug 9, 2023
1 parent 5a1540d commit 63d534c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions optimum/exporters/neuron/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,15 @@ def _get_submodels_for_export_stable_diffusion(
pipeline.unet.config.requires_aesthetics_score = getattr(pipeline.config, "requires_aesthetics_score", False)

# Replace original cross-attention module with custom cross-attention module for better performance
if not os.environ.get("NEURON_FUSE_SOFTMAX") == "1":
os.environ["NEURON_FUSE_SOFTMAX"] = "1"

Attention.get_attention_scores = get_attention_scores
# For applying optimized attention score, we need to set env variable `NEURON_FUSE_SOFTMAX=1`
if os.environ.get("NEURON_FUSE_SOFTMAX") == "1":
Attention.get_attention_scores = get_attention_scores
else:
logger.warning(
"We are not applying optimized attention score computation, which will harm the latency."
" If you want better performance, please set the environment variable with `export NEURON_FUSE_SOFTMAX=1`"
" and recompile the unet model again."
)
models_for_export["unet"] = copy.deepcopy(pipeline.unet)

# VAE Encoder
Expand Down

0 comments on commit 63d534c

Please sign in to comment.