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

Switch PyTorch PTQ to common implementation #2227

10 changes: 0 additions & 10 deletions nncf/experimental/torch/quantization/__init__.py

This file was deleted.

124 changes: 0 additions & 124 deletions nncf/experimental/torch/quantization/quantize_model.py

This file was deleted.

6 changes: 3 additions & 3 deletions nncf/quantization/quantize_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def quantize(
- `performance`: Symmetric quantization of weights and activations.
- `mixed`: Symmetric quantization of weights and asymmetric quantization of activations.
Default value is None. In this case, `mixed` preset is used for `transformer`
model type otherwise `performace`.
model type otherwise `performance`.
:type preset: nncf.QuantizationPreset
:param target_device: A target device the specificity of which will be taken
into account while compressing in order to obtain the best performance
Expand Down Expand Up @@ -185,7 +185,7 @@ def quantize_with_accuracy_control(
- `performance`: Symmetric quantization of weights and activations.
- `mixed`: Symmetric quantization of weights and asymmetric quantization of activations.
Default value is None. In this case, `mixed` preset is used for `transformer`
model type otherwise `performace`.
model type otherwise `performance`.
:type preset: nncf.QuantizationPreset
:param target_device: A target device the specificity of which will be taken
into account while compressing in order to obtain the best performance
Expand Down Expand Up @@ -317,7 +317,7 @@ def quantize_with_tune_hyperparams(
- `performance`: Symmetric quantization of weights and activations.
- `mixed`: Symmetric quantization of weights and asymmetric quantization of activations.
Default value is None. In this case, `mixed` preset is used for `transformer`
model type otherwise `performace`.
model type otherwise `performance`.
:param target_device: A target device the specificity of which will be taken
into account while compressing in order to obtain the best performance
for this type of device.
Expand Down
11 changes: 8 additions & 3 deletions nncf/torch/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Any, Dict, Union
from typing import Any, Dict, Tuple, Union

import torch
from torch import nn
Expand All @@ -32,12 +32,17 @@ def __init__(self, model: nn.Module):
self._model = model
self._model.eval()

def infer(self, input_data: Union[torch.Tensor, Dict[str, torch.Tensor]]) -> Union[torch.Tensor, Dict[str, Any]]:
def infer(
self, input_data: Union[torch.Tensor, Tuple[torch.Tensor], Dict[str, torch.Tensor]]
) -> Union[torch.Tensor, Dict[str, Any]]:
"""
Runs Torch model on the provided input.

:param input_data: inputs for the model
:return output_data: model outputs
"""
AlexanderDokuchaev marked this conversation as resolved.
Show resolved Hide resolved

if isinstance(input_data, dict):
return self._model(**input_data)
if isinstance(input_data, tuple):
return self._model(*input_data)
vshampor marked this conversation as resolved.
Show resolved Hide resolved
return self._model(input_data)
Loading