Skip to content
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

Fix is inference mode #711

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions ppdiffusers/ppdiffusers/pipelines/dit/pipeline_dit.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
from ...utils.paddle_utils import randn_tensor
from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput

try:
# paddle.incubate.jit.inference is available in paddle develop but not in paddle 3.0beta, so we add a try except.
from paddle.incubate.jit import is_inference_mode
except:

def is_inference_mode(func):
return False


class DiTPipeline(DiffusionPipeline):
r"""
Expand Down Expand Up @@ -192,7 +200,7 @@ def __call__(
)
# predict noise model_output
noise_pred_out = self.transformer(latent_model_input, timestep=timesteps, class_labels=class_labels_input)
if paddle.incubate.jit.is_inference_mode(self.transformer):
if is_inference_mode(self.transformer):
# self.transformer run in paddle inference.
noise_pred = noise_pred_out
else:
Expand Down Expand Up @@ -227,7 +235,7 @@ def __call__(
latents = 1 / self.vae.config.scaling_factor * latents

samples_out = self.vae.decode(latents)
if paddle.incubate.jit.is_inference_mode(self.vae.decode):
if is_inference_mode(self.vae.decode):
# self.vae.decode run in paddle inference.
samples = samples_out
else:
Expand Down