-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Changes Introduce TORCH2 backend MinMax algorithms for torch2 backend Add handle_torch_function for quantization function to trace it by torch_function ### Related tickets 152996 ### Tests [test install](https://github.com/openvinotoolkit/nncf/actions/runs/13014595451)
- Loading branch information
1 parent
6565033
commit 5ad9bc4
Showing
46 changed files
with
14,748 additions
and
125 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
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
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
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
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,21 @@ | ||
# Copyright (c) 2025 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 os | ||
|
||
|
||
def is_experimental_torch_tracing_enabled() -> bool: | ||
""" | ||
Checks if experimental torch tracing is enabled by environment variable NNCF_EXPERIMENTAL_TORCH_TRACING. | ||
:return: True if experimental torch tracing is enabled, False otherwise. | ||
""" | ||
return os.getenv("NNCF_EXPERIMENTAL_TORCH_TRACING") is not None |
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,43 @@ | ||
# Copyright (c) 2025 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. | ||
|
||
from typing import List, Optional | ||
|
||
from torch import nn | ||
|
||
from nncf.common.graph.transformations.commands import Command | ||
from nncf.common.graph.transformations.commands import TransformationType | ||
from nncf.experimental.torch2.function_hook.hook_storage import RemovableHookHandle | ||
from nncf.torch.graph.transformations.commands import PTTargetPoint | ||
|
||
|
||
class PT2InsertionCommand(Command): | ||
""" | ||
Insertion operation to the models. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
target_points: List[PTTargetPoint], | ||
hook_module: nn.Module, | ||
*, | ||
handle_storage: Optional[List[RemovableHookHandle]] = None, | ||
): | ||
""" | ||
:param target_points: The list of target points for the command. | ||
:param hook_module: The hook module for the command that will be inserted into the model | ||
to execute at the target points. | ||
:param handle_storage: The handle storage for the command to collect RemovableHookHandle. Defaults to None. | ||
""" | ||
super().__init__(TransformationType.INSERT) | ||
self.target_points = target_points | ||
self.hook_module = hook_module | ||
self.handle_storage = handle_storage |
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
Oops, something went wrong.