Skip to content

Commit

Permalink
update after migration on new pipeline style
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova committed Oct 11, 2024
1 parent ea19b9a commit 37a39dd
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 27 deletions.
9 changes: 6 additions & 3 deletions optimum/exporters/openvino/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
from optimum.exporters.onnx.convert import export_tensorflow as export_tensorflow_onnx
from optimum.exporters.utils import (
_get_submodels_and_export_configs as _default_get_submodels_and_export_configs,
)
from optimum.exporters.utils import (
get_diffusion_models_for_export,
)
from optimum.intel.utils.import_utils import (
Expand Down Expand Up @@ -621,6 +623,7 @@ def export_from_model(

if library_name == "diffusers":
export_config, models_and_export_configs = get_diffusion_models_for_export_ext(model, exporter="openvino")
stateful_submodels = False
else:
logging.disable(logging.INFO)
export_config, models_and_export_configs, stateful_submodels = _get_submodels_and_export_configs(
Expand All @@ -636,7 +639,7 @@ def export_from_model(
_variant="default",
legacy=False,
exporter="openvino",
stateful=stateful
stateful=stateful,
)
logging.disable(logging.NOTSET)

Expand Down Expand Up @@ -954,7 +957,7 @@ def get_diffusion_models_for_export_ext(

# VAE Encoder https://github.com/huggingface/diffusers/blob/v0.11.1/src/diffusers/models/vae.py#L565
vae_encoder = copy.deepcopy(pipeline.vae)
vae_encoder.forward = lambda sample: {"latent_sample": vae_encoder.encode(x=sample)["latent_dist"].sample()}
vae_encoder.forward = lambda sample: {"latent_parameters": vae_encoder.encode(x=sample)["latent_dist"].parameters}
vae_config_constructor = TasksManager.get_exporter_config_constructor(
model=vae_encoder,
exporter=exporter,
Expand Down Expand Up @@ -1008,4 +1011,4 @@ def get_diffusion_models_for_export_ext(
export_config = export_config_constructor(text_encoder_3.config, int_dtype=int_dtype, float_dtype=float_dtype)
models_for_export["text_encoder_3"] = (text_encoder_3, export_config)

return None, models_for_export, False
return None, models_for_export
2 changes: 1 addition & 1 deletion optimum/exporters/openvino/model_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
MistralOnnxConfig,
MPTOnnxConfig,
PhiOnnxConfig,
UNetOnnxConfig,
VisionOnnxConfig,
)
from optimum.exporters.tasks import TasksManager
Expand Down Expand Up @@ -1524,7 +1525,6 @@ def patch_model_for_export(
return InternVLChatImageEmbeddingModelPatcher(self, model, model_kwargs)



class PooledProjectionsDummyInputGenerator(DummyInputGenerator):
SUPPORTED_INPUT_NAMES = "pooled_projection"

Expand Down
Loading

0 comments on commit 37a39dd

Please sign in to comment.