Skip to content

Commit

Permalink
Applied some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKoff88 committed Dec 15, 2023
1 parent effb744 commit 96f0af5
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion optimum/commands/export/openvino.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.
"""Defines the command line for the export with OpenVINO."""

import logging
import sys
from pathlib import Path
from typing import TYPE_CHECKING, Optional
Expand All @@ -21,6 +22,9 @@
from ..base import BaseOptimumCLICommand, CommandInfo


logger = logging.getLogger(__name__)


if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace, _SubParsersAction

Expand Down Expand Up @@ -68,6 +72,8 @@ def parse_args_openvino(parser: "ArgumentParser"):
"This is needed by some models, for some tasks. If not provided, will attempt to use the tokenizer to guess it."
),
)
optional_group.add_argument("--fp16", action="store_true", help="Compress weights to fp16")
optional_group.add_argument("--int8", action="store_true", help="Compress weights to int8")
optional_group.add_argument(
"--weight-format",
type=str,
Expand All @@ -81,7 +87,10 @@ def parse_args_openvino(parser: "ArgumentParser"):
"--ratio",
type=float,
default=0.8,
help="Compression ratio between primary and backup precision (only applicable to INT4 type).",
help=(
"Compression ratio between primary and backup precision. In the case of INT4, NNCF evaluates layer sensitivity and keeps the most impactful layers in INT8"
"precision (by default 20% in INT8). This helps to achieve better accuracy after weight quantization."
),
)


Expand All @@ -108,6 +117,17 @@ def parse_args(parser: "ArgumentParser"):
def run(self):
from ...exporters.openvino.__main__ import main_export

if self.args.fp16:
logger.warning(
"`--fp16` option is deprecated and will be removed in a future version. Use `--weight-format` instead."
)
self.args.weight_format = "f16"
if self.args.int8:
logger.warning(
"`--int8` option is deprecated and will be removed in a future version. Use `--weight-format` instead."
)
self.args.weight_format = "i8"

# TODO : add input shapes
main_export(
model_name_or_path=self.args.model,
Expand Down

0 comments on commit 96f0af5

Please sign in to comment.