Skip to content

Commit

Permalink
Unstage helper scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-savelyevv committed Oct 22, 2024
1 parent c22090b commit eef34f8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 625 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.


# Copyright (c) 2024 Intel Corporation
# 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.

import inspect
from dataclasses import dataclass
from typing import List, Optional, Tuple
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ def calculate_quantization_params(
factor = 1.0 - 0.05 * scale_step
scaled_scale = factor * scale

input_tensors[1] = scaled_scale.data
if config.mode == CompressWeightsMode.NF4:
out = do_nf4_quantization(original_weight, scaled_scale)
else:
Expand All @@ -318,7 +317,6 @@ def calculate_quantization_params(
near_to_ideal_scale = estimate_scales(original_weight, target, zero_mask, importance)
near_to_ideal_scale = near_to_ideal_scale * scale_sign

input_tensors[1] = near_to_ideal_scale.data
if config.mode == CompressWeightsMode.NF4:
g_compressed_weighs = do_nf4_quantization(original_weight, near_to_ideal_scale)
out = do_nf4_dequantization(g_compressed_weighs, near_to_ideal_scale)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
import nncf
from nncf.parameters import CompressWeightsMode
from nncf.quantization.algorithms.weight_compression.config import WeightCompressionConfig
from nncf.quantization.algorithms.weight_compression.openvino_modeling import OVModelParameters, \
get_compress_decompress_weight_model, get_compress_weight_model
from nncf.quantization.algorithms.weight_compression.openvino_modeling import OVModelParameters
from nncf.quantization.algorithms.weight_compression.openvino_modeling import get_compress_decompress_weight_model
from nncf.quantization.algorithms.weight_compression.openvino_modeling import get_compress_weight_model
from nncf.quantization.fake_quantize import calculate_scale_zero_point
from nncf.tensor import Tensor
from nncf.tensor import functions as fns
Expand Down Expand Up @@ -492,8 +493,12 @@ def do_int_quantization(


def calculate_quantized_dequantized_weight(
weight: Tensor, config: WeightCompressionConfig, scale: Tensor, zero_point: Optional[Tensor] = None,
invert_division: Optional[bool] = False, ov_model_params: Optional[OVModelParameters] = None,
weight: Tensor,
config: WeightCompressionConfig,
scale: Tensor,
zero_point: Optional[Tensor] = None,
invert_division: Optional[bool] = False,
ov_model_params: Optional[OVModelParameters] = None,
) -> Tensor:
accelerate_through_ov = is_openvino_available()

Expand Down
11 changes: 11 additions & 0 deletions nncf/tensor/functions/ov.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Copyright (c) 2024 Intel Corporation
# 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.

import numpy as np
import openvino as ov

Expand Down
Loading

0 comments on commit eef34f8

Please sign in to comment.