-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
107 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
from .__main__ import main_export | ||
from .base import init_model_configs | ||
from .convert import export, export_from_model, export_models, export_pytorch_via_onnx | ||
from .model_configs import * | ||
from .stateful import ensure_stateful_is_available, patch_stateful | ||
|
||
|
||
init_model_configs() | ||
|
||
|
||
__all__ = ["main_export", "export", "export_models"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright 2022 The HuggingFace Team. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from copy import deepcopy | ||
|
||
from optimum.exporters.tasks import TasksManager | ||
|
||
|
||
def init_model_configs(): | ||
suppored_models = TasksManager._SUPPORTED_MODEL_TYPE | ||
for model, export_configs in suppored_models.items(): | ||
if "onnx" not in export_configs: | ||
continue | ||
TasksManager._SUPPORTED_MODEL_TYPE[model]["openvino"] = deepcopy( | ||
TasksManager._SUPPORTED_MODEL_TYPE[model]["onnx"] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Copyright 2024 The HuggingFace Team. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
from optimum.exporters.onnx.config import TextDecoderOnnxConfig, TextDecoderWithPositionIdsOnnxConfig | ||
from optimum.exporters.tasks import TasksManager | ||
from optimum.utils.input_generators import DummyTextInputGenerator, MistralDummyPastKeyValuesGenerator | ||
from optimum.utils.normalized_config import NormalizedTextConfig | ||
|
||
|
||
register_in_tasks_manager = TasksManager.create_register("openvino", overwrite_existing=True) | ||
|
||
|
||
@register_in_tasks_manager("baichuan", *["text-generation", "text-generation-with-past"]) | ||
class BaichaunOpenVINOConfig(TextDecoderOnnxConfig): | ||
DEFAULT_ONNX_OPSET = 13 | ||
NORMALIZED_CONFIG_CLASS = NormalizedTextConfig.with_args( | ||
num_layers="num_hidden_layers", num_attention_heads="num_attention_heads", hidden_size="hidden_size" | ||
) | ||
|
||
|
||
@register_in_tasks_manager("jais", *["text-generation", "text-generation-with-past"]) | ||
class JaisOpenVINOConfig(TextDecoderOnnxConfig): | ||
DEFAULT_ONNX_OPSET = 13 | ||
NORMALIZED_CONFIG_CLASS = NormalizedTextConfig.with_args( | ||
num_layers="n_layer", num_attention_heads="n_head", hidden_size="n_embd" | ||
) | ||
|
||
|
||
@register_in_tasks_manager("qwen2", *["text-generation", "text-generation-with-past"]) | ||
class Qwen2OpenVINOConfig(TextDecoderWithPositionIdsOnnxConfig): | ||
DEFAULT_ONNX_OPSET = 14 | ||
|
||
DUMMY_INPUT_GENERATOR_CLASSES = (DummyTextInputGenerator, MistralDummyPastKeyValuesGenerator) | ||
DUMMY_PKV_GENERATOR_CLASS = MistralDummyPastKeyValuesGenerator | ||
NORMALIZED_CONFIG_CLASS = NormalizedTextConfig | ||
|
||
|
||
@register_in_tasks_manager("minicpm", *["text-generation", "text-generation-with-past"]) | ||
class MiniCPMOpenVINOConfig(TextDecoderWithPositionIdsOnnxConfig): | ||
DEFAULT_ONNX_OPSET = 14 | ||
|
||
DUMMY_INPUT_GENERATOR_CLASSES = (DummyTextInputGenerator, MistralDummyPastKeyValuesGenerator) | ||
DUMMY_PKV_GENERATOR_CLASS = MistralDummyPastKeyValuesGenerator | ||
NORMALIZED_CONFIG_CLASS = NormalizedTextConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters