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

[Good First Issue][NNCF]: Remove backend-specific methods from the common layer attributes #3249

Closed
daniil-lyakhov opened this issue Feb 4, 2025 · 8 comments · Fixed by #3287
Assignees
Labels
good first issue Good for newcomers

Comments

@daniil-lyakhov
Copy link
Collaborator

daniil-lyakhov commented Feb 4, 2025

Context

Greetings, fellow scientists😺!

Recently we've discovered an old code that becomes confusing when used with the latest algorithms:

https://github.com/openvinotoolkit/nncf/blob/develop/nncf/common/graph/layer_attributes.py#L56-L79
https://github.com/openvinotoolkit/nncf/blob/develop/nncf/common/graph/layer_attributes.py#L135-L136

the problematic methods are get_weights_shape, get_target_dim_for_compression and get_bias_shape . Current algorithms use NNCFGraph to retrieve correct info, and not every backend follow the hardcoded weights shape layout / compression dim.

What needs to be done?

The task is to create the following functions in the https://github.com/openvinotoolkit/nncf/blob/develop/nncf/common/graph/utils.py file:

  • get_weights_shape_legacy(layer_attributes: WeightedLayerAttributes)
  • get_target_dim_for_compression_legacy(layer_attributes: WeightedLayerAttributes)
  • get_bias_shape_legacy(layer_attributes: WeightedLayerAttributes)

Additionally, all calls to the following methods should be replaced with their corresponding legacy function calls:

  • get_weights_shape -> get_weights_shape_legacy
  • get_target_dim_for_compression -> get_target_dim_for_compression_legacy
  • get_bias_shape -> get_bias_shape_legacy

Furthermore, the docstrings of these methods should clarify that they are valid only for PyTorch and TensorFlow backends.

Example Pull Requests

#3179

Resources

Contact points

@daniil-lyakhov

Ticket

No response

@shumaari
Copy link
Contributor

shumaari commented Feb 4, 2025

.take

Copy link

github-actions bot commented Feb 4, 2025

Thank you for looking into this issue! Please let us know if you have any questions or require any help.

@github-project-automation github-project-automation bot moved this to Contributors Needed in Good first issues Feb 4, 2025
@ljaljushkin ljaljushkin moved this from Contributors Needed to Assigned in Good first issues Feb 4, 2025
@shumaari
Copy link
Contributor

shumaari commented Feb 6, 2025

@daniil-lyakhov

I am still looking into the issue and would like to clarify my understanding:

Function calls for three methods need to be replaced by their legacy versions

layer_attributes.get_weight_shape -> layer_attributes.get_weight_shape_legacy
layer_attributes.get_target_dim_for_compression -> layer_attributes.get_target_dim_for_compression_legacy
layer_attributes.get_bias_shape -> layer_attributes.get_bias_shape_legacy

Possible locations for layer_attributes.get_weight_shape

https://github.com/openvinotoolkit/nncf/blob/develop/nncf/experimental/tensorflow/quantization/algorithm.py#L136
https://github.com/openvinotoolkit/nncf/blob/develop/nncf/experimental/torch/sparsity/movement/layers.py#L170
https://github.com/openvinotoolkit/nncf/blob/develop/nncf/experimental/torch/sparsity/movement/structured_mask_handler.py#L212
https://github.com/openvinotoolkit/nncf/blob/develop/nncf/torch/quantization/algo.py#L776
https://github.com/openvinotoolkit/nncf/blob/develop/nncf/torch/quantization/algo.py#L1185
https://github.com/openvinotoolkit/nncf/blob/develop/nncf/torch/quantization/init_range.py#L229
https://github.com/openvinotoolkit/nncf/blob/develop/nncf/torch/sparsity/const/algo.py#L29
https://github.com/openvinotoolkit/nncf/blob/develop/nncf/torch/sparsity/magnitude/algo.py#L47
https://github.com/openvinotoolkit/nncf/blob/develop/nncf/torch/sparsity/rb/algo.py#L47

Possible locations for layer_attributes.get_target_dim_for_compression

https://github.com/openvinotoolkit/nncf/blob/develop/nncf/experimental/common/pruning/nodes_grouping.py#L79
https://github.com/openvinotoolkit/nncf/blob/develop/nncf/torch/quantization/algo.py#L779
https://github.com/openvinotoolkit/nncf/blob/develop/nncf/torch/quantization/init_range.py#L230

Possible locations for layer_attributes.get_bias_shape

https://github.com/openvinotoolkit/nncf/blob/develop/nncf/experimental/torch/sparsity/movement/layers.py#L188
https://github.com/openvinotoolkit/nncf/blob/develop/nncf/experimental/torch/sparsity/movement/structured_mask_handler.py#L214

Create the three legacy methods with docstrings

I am still unclear about where these functions could be created? Within class definitions for WeightedLayerAttributes and LinearLayerAttributes classes in https://github.com/openvinotoolkit/nncf/blob/develop/nncf/common/graph/layer_attributes.py like below or somewhere else?

Image

I would also like to mention that get_weight_shape_legacy and get_target_dim_for_compression_legacy methods in WeightedLayerAttributes class are mere placeholders. The method which caused the reported error in #3230 (comment) must be defined elsewhere.

I intend to recreate the error reported above. What else can I do to investigate further?

@daniil-lyakhov
Copy link
Collaborator Author

Hi @shumaari,

List of the method usage is correct, thanks for your analysis. I'm apologies for not clear instructions, the task is to create 3 functions (not class methods) in the https://github.com/openvinotoolkit/nncf/blob/develop/nncf/common/graph/utils.py file. Then, the assignee have to replate method calls with the functions calls.

Please don't spend too much time on the error reproduction: it isn't a error indeed, it is a wrong usage of a backend-specific method

@shumaari
Copy link
Contributor

shumaari commented Feb 12, 2025

Hi @daniil-lyakhov

Thank you for the clarifying the location of new (legacy) methods.

I am still looking into the issue and would like to confirm that I am on the right track:

  1. (as shared before) There are 14 possible locations for corrections, 9 for layer_attributes.get_weight_shape, 3 for layer_attributes.get_target_dim_for_compression, 2 for layer_attributes.get_bias_shape
  2. The locations are split as follows:
    a. 4 in https://github.com/openvinotoolkit/nncf/blob/develop/nncf/experimental/torch/ folder (torch backend)
    b. 8 in https://github.com/openvinotoolkit/nncf/blob/develop/nncf/torch/ folder (torch backend)
    c. 1 in https://github.com/openvinotoolkit/nncf/blob/develop/nncf/experimental/tensorflow/ folder (tensorflow backend)
    d. 1 in https://github.com/openvinotoolkit/nncf/blob/develop/nncf/experimental/common/pruning/ folder (common to both torch and tensorflow backends)

Question: The methods need to be replaced in all these four contexts?

  1. In each of these 14 locations, the method argument layer_attributes is the value for "layer_attributes" key in the _attributes dictionary for NNCFNode object
  2. This layer_attributes value is an instance of BaseLayerAttributes class or one of its subclasses. However, the methods may differ based on the subclass.

Question: Should the new (legacy) methods contain branched logic based on which subclass the instance belongs to, or should it contain code that is applicable directly to all subclasses? (I am not sure if the latter is actually possible.) If branched logic needs to be followed, can the relevant class methods be called or does the code need to be self-contained?

  1. In some of the locations it is not immediately apparent which subclass of BaseLayerAttributes layer_attributes belongs to.

Question: Is it safe to assume that it belongs to one of the two subclasses, GenericWeightedLayerAttributes or LinearLayerAttributes unless explicitly clear otherwise?

Thank you for your patience and guidance!

@daniil-lyakhov
Copy link
Collaborator Author

daniil-lyakhov commented Feb 12, 2025

Hi @shumaari, let me answer your questions in form of a pseudocode:
in file https://github.com/openvinotoolkit/nncf/blob/develop/nncf/common/graph/utils.py

def get_weights_shape_legacy(layer_attributes: GenericWeightedLayerAttributes):
    if isinstance(layer_attributes, LinearLayerAttribute):
        # Code copied from the LinerLayerAttribute
    if isinstance(layer_attributes, ConvolutionLayerAttribute):
        # Code copied from the ConvolutionLayerAttribute
    # etc for each child of the GenericWeightedLayerAttributes
    ....

def get_target_dim_for_compression_legacy(layer_attributes: GenericWeightedLayerAttributes):
    # Same logic as above
    ...

def get_bias_shape_legacy(layer_attributes: GenericWeightedLayerAttributes):
    # Same logic as above
    ....

Then the removed layer attributes methods should be replaced like this:

layer_attribute.get_weights_shape() -> get_weights_shape_legacy(layer_attribute)

Please don't list all the places you are going to update, just open a draft PR with your changes. It would be easier to comment on the actual code.

Regarding 3 and 4: there are different layer attribute classes in the NNCF, please replace the usage of the methods only for those which are parents of GenericWeightedLayerAttributes and keep all other layer attributes as it is. BaseLayerAttributes does not have get_weights_shape, get_target_dim_for_compression and get_bias_shape methods, thus you shouldn't change it

shumaari added a commit to shumaari/nncf that referenced this issue Feb 17, 2025
Changes:

Moved and renamed backend-specific class method from common layer
attributes in nncf/common/graph/layer_attributes.py to self-contained
function in nncf/common/graph/utils.py
- layer_attributes.get_weight_shape ->
get_weight_shape_legacy(layer_attributes: WeightedLayerAttributes)

Reason for changes:

(openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed
from common layer attributes and all related calls need to be replaced
by their corresponding legacy function calls
shumaari added a commit to shumaari/nncf that referenced this issue Feb 17, 2025
…olkit#3249)

Changes:

Moved and renamed backend-specific class method from common layer
attributes in nncf/common/graph/layer_attributes.py to self-contained
function in nncf/common/graph/utils.py
- layer_attributes.get_target_dim_for_compression ->
get_target_dim_for_compression_legacy(layer_attributes: WeightedLayerAttributes)

Reason for changes:

(openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed
from common layer attributes and all related calls need to be replaced
by their corresponding legacy function calls
shumaari added a commit to shumaari/nncf that referenced this issue Feb 17, 2025
Changes:

Moved and renamed backend-specific class method from common layer
attributes in nncf/common/graph/layer_attributes.py to self-contained
function in nncf/common/graph/utils.py
- layer_attributes.get_bias_shape ->
get_bias_shape_legacy(layer_attributes: WeightedLayerAttributes)

Reason for changes:

(openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed
from common layer attributes and all related calls need to be replaced
by their corresponding legacy function calls
shumaari added a commit to shumaari/nncf that referenced this issue Feb 17, 2025
Changes:

Calls to following class methods in
nncf/common/graph/layer_attributes.py were replaced with calls to their
corresponding self-contained legacy functions in
nncf/common/graph/utils.py:
- layer_attributes.get_weight_shape ->
get_weight_shape_legacy(layer_attributes: WeightedLayerAttributes)
- layer_attributes.get_bias_shape ->
get_bias_shape_legacy(layer_attributes: WeightedLayerAttributes)

Locations in /nncf/experimental/torch/sparsity/movement/ folder
  - layers.py
  - structured_mask_handler.py

Reason for changes:

(openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed
from common layer attributes and all related calls need to be replaced
by their corresponding legacy function calls
shumaari added a commit to shumaari/nncf that referenced this issue Feb 17, 2025
Changes:

Call to following class method in
nncf/common/graph/layer_attributes.py was replaced with call to its
corresponding self-contained legacy function in
nncf/common/graph/utils.py:
- layer_attributes.get_weight_shape ->
get_weight_shape_legacy(layer_attributes: WeightedLayerAttributes)

Location in /nncf/experimental/tensorflow/quantization/ folder
  - algorithm.py

Reason for changes:

(openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed
from common layer attributes and all related calls need to be replaced
by their corresponding legacy function calls
shumaari added a commit to shumaari/nncf that referenced this issue Feb 17, 2025
Changes:

Call to following class method in
nncf/common/graph/layer_attributes.py was replaced with call to its
corresponding self-contained legacy function in
nncf/common/graph/utils.py:
- layer_attributes.get_target_dim_for_compression ->
get_target_dim_for_compression_legacy(
    layer_attributes: WeightedLayerAttributes)

Locations in /nncf/experimental/common/pruning/
  - nodes_grouping.py

Reason for changes:

(openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed
from common layer attributes and all related calls need to be replaced
by their corresponding legacy function calls
shumaari added a commit to shumaari/nncf that referenced this issue Feb 17, 2025
Changes:

Calls to following class methods in
nncf/common/graph/layer_attributes.py were replaced with calls to their
corresponding self-contained legacy functions in
nncf/common/graph/utils.py:
- layer_attributes.get_weight_shape ->
get_weight_shape_legacy(layer_attributes: WeightedLayerAttributes)
- layer_attributes.get_target_dim_for_compression ->
get_target_dim_for_compression_legacy(
    layer_attributes: WeightedLayerAttributes)

Locations in /nncf/torch/quantization folder
  - algo.py
  - init_range.py

Reason for changes:

(openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed
from common layer attributes and all related calls need to be replaced
by their corresponding legacy function calls
shumaari added a commit to shumaari/nncf that referenced this issue Feb 17, 2025
…olkit#3249)

Changes:

Moved and renamed backend-specific class method from common layer
attributes in nncf/common/graph/layer_attributes.py to self-contained
function in nncf/common/graph/utils.py
- layer_attributes.get_target_dim_for_compression ->
get_target_dim_for_compression_legacy(layer_attributes: WeightedLayerAttributes)

Reason for changes:

(openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed
from common layer attributes and all related calls need to be replaced
by their corresponding legacy function calls
shumaari added a commit to shumaari/nncf that referenced this issue Feb 17, 2025
Changes:

Moved and renamed backend-specific class method from common layer
attributes in nncf/common/graph/layer_attributes.py to self-contained
function in nncf/common/graph/utils.py
- layer_attributes.get_bias_shape ->
get_bias_shape_legacy(layer_attributes: WeightedLayerAttributes)

Reason for changes:

(openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed
from common layer attributes and all related calls need to be replaced
by their corresponding legacy function calls
shumaari added a commit to shumaari/nncf that referenced this issue Feb 17, 2025
Changes:

Calls to following class methods in
nncf/common/graph/layer_attributes.py were replaced with calls to their
corresponding self-contained legacy functions in
nncf/common/graph/utils.py:
- layer_attributes.get_weight_shape ->
get_weight_shape_legacy(layer_attributes: WeightedLayerAttributes)
- layer_attributes.get_bias_shape ->
get_bias_shape_legacy(layer_attributes: WeightedLayerAttributes)

Locations in /nncf/experimental/torch/sparsity/movement/ folder
  - layers.py
  - structured_mask_handler.py

Reason for changes:

(openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed
from common layer attributes and all related calls need to be replaced
by their corresponding legacy function calls
shumaari added a commit to shumaari/nncf that referenced this issue Feb 17, 2025
Changes:

Call to following class method in
nncf/common/graph/layer_attributes.py was replaced with call to its
corresponding self-contained legacy function in
nncf/common/graph/utils.py:
- layer_attributes.get_weight_shape ->
get_weight_shape_legacy(layer_attributes: WeightedLayerAttributes)

Location in /nncf/experimental/tensorflow/quantization/ folder
  - algorithm.py

Reason for changes:

(openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed
from common layer attributes and all related calls need to be replaced
by their corresponding legacy function calls
shumaari added a commit to shumaari/nncf that referenced this issue Feb 17, 2025
Changes:

Call to following class method in
nncf/common/graph/layer_attributes.py was replaced with call to its
corresponding self-contained legacy function in
nncf/common/graph/utils.py:
- layer_attributes.get_target_dim_for_compression ->
get_target_dim_for_compression_legacy(
    layer_attributes: WeightedLayerAttributes)

Locations in /nncf/experimental/common/pruning/
  - nodes_grouping.py

Reason for changes:

(openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed
from common layer attributes and all related calls need to be replaced
by their corresponding legacy function calls
shumaari added a commit to shumaari/nncf that referenced this issue Feb 17, 2025
Changes:

Calls to following class methods in
nncf/common/graph/layer_attributes.py were replaced with calls to their
corresponding self-contained legacy functions in
nncf/common/graph/utils.py:
- layer_attributes.get_weight_shape ->
get_weight_shape_legacy(layer_attributes: WeightedLayerAttributes)
- layer_attributes.get_target_dim_for_compression ->
get_target_dim_for_compression_legacy(
    layer_attributes: WeightedLayerAttributes)

Locations in /nncf/torch/quantization folder
  - algo.py
  - init_range.py

Reason for changes:

(openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed
from common layer attributes and all related calls need to be replaced
by their corresponding legacy function calls
shumaari added a commit to shumaari/nncf that referenced this issue Feb 17, 2025
Changes:

Moved and renamed backend-specific class method from common layer
attributes in nncf/common/graph/layer_attributes.py to self-contained
function in nncf/common/graph/utils.py
- layer_attributes.get_weight_shape ->
get_weight_shape_legacy(layer_attributes: WeightedLayerAttributes)

Reason for changes:

(openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed
from common layer attributes and all related calls need to be replaced
by their corresponding legacy function calls
shumaari added a commit to shumaari/nncf that referenced this issue Feb 17, 2025
…olkit#3249)

Changes:

Moved and renamed backend-specific class method from common layer
attributes in nncf/common/graph/layer_attributes.py to self-contained
function in nncf/common/graph/utils.py
- layer_attributes.get_target_dim_for_compression ->
get_target_dim_for_compression_legacy(layer_attributes: WeightedLayerAttributes)

Reason for changes:

(openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed
from common layer attributes and all related calls need to be replaced
by their corresponding legacy function calls
shumaari added a commit to shumaari/nncf that referenced this issue Feb 17, 2025
Changes:

Moved and renamed backend-specific class method from common layer
attributes in nncf/common/graph/layer_attributes.py to self-contained
function in nncf/common/graph/utils.py
- layer_attributes.get_bias_shape ->
get_bias_shape_legacy(layer_attributes: WeightedLayerAttributes)

Reason for changes:

(openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed
from common layer attributes and all related calls need to be replaced
by their corresponding legacy function calls
shumaari added a commit to shumaari/nncf that referenced this issue Feb 17, 2025
Changes:

Calls to following class methods in
nncf/common/graph/layer_attributes.py were replaced with calls to their
corresponding self-contained legacy functions in
nncf/common/graph/utils.py:
- layer_attributes.get_weight_shape ->
get_weight_shape_legacy(layer_attributes: WeightedLayerAttributes)
- layer_attributes.get_bias_shape ->
get_bias_shape_legacy(layer_attributes: WeightedLayerAttributes)

Locations in /nncf/experimental/torch/sparsity/movement/ folder
  - layers.py
  - structured_mask_handler.py

Reason for changes:

(openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed
from common layer attributes and all related calls need to be replaced
by their corresponding legacy function calls
shumaari added a commit to shumaari/nncf that referenced this issue Feb 17, 2025
Changes:

Call to following class method in
nncf/common/graph/layer_attributes.py was replaced with call to its
corresponding self-contained legacy function in
nncf/common/graph/utils.py:
- layer_attributes.get_weight_shape ->
get_weight_shape_legacy(layer_attributes: WeightedLayerAttributes)

Location in /nncf/experimental/tensorflow/quantization/ folder
  - algorithm.py

Reason for changes:

(openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed
from common layer attributes and all related calls need to be replaced
by their corresponding legacy function calls
shumaari added a commit to shumaari/nncf that referenced this issue Feb 17, 2025
Changes:

Call to following class method in
nncf/common/graph/layer_attributes.py was replaced with call to its
corresponding self-contained legacy function in
nncf/common/graph/utils.py:
- layer_attributes.get_target_dim_for_compression ->
get_target_dim_for_compression_legacy(
    layer_attributes: WeightedLayerAttributes)

Locations in /nncf/experimental/common/pruning/
  - nodes_grouping.py

Reason for changes:

(openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed
from common layer attributes and all related calls need to be replaced
by their corresponding legacy function calls
shumaari added a commit to shumaari/nncf that referenced this issue Feb 17, 2025
Changes:

Calls to following class methods in
nncf/common/graph/layer_attributes.py were replaced with calls to their
corresponding self-contained legacy functions in
nncf/common/graph/utils.py:
- layer_attributes.get_weight_shape ->
get_weight_shape_legacy(layer_attributes: WeightedLayerAttributes)
- layer_attributes.get_target_dim_for_compression ->
get_target_dim_for_compression_legacy(
    layer_attributes: WeightedLayerAttributes)

Locations in /nncf/torch/quantization folder
  - algo.py
  - init_range.py

Reason for changes:

(openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed
from common layer attributes and all related calls need to be replaced
by their corresponding legacy function calls
@shumaari
Copy link
Contributor

@daniil-lyakhov

Apologies for the clutter above. I have created a draft pull request 3287 . Could you please provide feedback?

Thank you!

shumaari added a commit to shumaari/nncf that referenced this issue Feb 17, 2025
Changes:

Removed backend-specific class methods from common layer attributes in
nncf/common/graph/layer_attributes.py
- get_weight_shape
- get_target_dim_for_compression
- get_bias_shape

Reason for changes:

(openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed
from common layer attributes and all related calls need to be replaced
by their corresponding legacy function calls
shumaari added a commit to shumaari/nncf that referenced this issue Feb 18, 2025
Changes:

1. Added missing import statements in nncf/common/graph/utils.py

Reason for changes:

(openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed
from common layer attributes and all related calls need to be replaced
by their corresponding legacy function calls
AlexanderDokuchaev pushed a commit that referenced this issue Feb 25, 2025
…ibutes (#3287)

### Changes

1. Moved and renamed backend-specific class methods from common layer
attributes in nncf/common/graph/layer_attributes.py to self-contained 
functions in nncf/common/graph/utils.py
- layer_attributes.get_bias_shape -> 
get_bias_shape_legacy(layer_attributes: WeightedLayerAttributes)
- layer_attributes.get_num_filters ->
get_num_filters_legacy(layer_attributes: WeightedLayerAttributes)
- layer_attributes.get_target_dim_for_compression -> 
get_target_dim_for_compression_legacy(layer_attributes:
WeightedLayerAttributes)
- layer_attributes.get_weight_shape -> 
get_weight_shape_legacy(layer_attributes: WeightedLayerAttributes)


2. Calls to above class methods were replaced with calls to their
corresponding legacy functions in the following locations
- /nncf/experimental/common/ folder
  - pruning/nodes_grouping.py
- /nncf/experimental/tensorflow/ folder
  - quantization/algorithm.py
- /nncf/experimental/torch/ folder
  - nas/bootstrapNAS/elasticity/elastic_width.py
  - sparsity/movement/layers.py
  - sparsity/movement/structured_mask_handler.py
- /nncf/torch/ folder
  - quantization/algo.py
  - quantization/init_range.py
  - sparsity/const/algo.py
  - sparsity/magnitude/algo.py
  - sparsity/rb/algo.py


### Reason for changes

Torch and Tensorflow backend-specific methods need to be removed 
from common layer attributes and all related calls need to be replaced 
by their corresponding legacy function calls (resolves #3249)
@github-project-automation github-project-automation bot moved this from Assigned to Closed in Good first issues Feb 25, 2025
@daniil-lyakhov
Copy link
Collaborator Author

@shumaari, thank you for your contribution! We are looking forward to collaborate with you in future!

shumaari added a commit to shumaari/nncf that referenced this issue Mar 8, 2025
…mmon layer attributes (openvinotoolkit#3287)

### Changes

1. Moved and renamed backend-specific class methods from common layer
attributes in nncf/common/graph/layer_attributes.py to self-contained 
functions in nncf/common/graph/utils.py
- layer_attributes.get_bias_shape -> 
get_bias_shape_legacy(layer_attributes: WeightedLayerAttributes)
- layer_attributes.get_num_filters ->
get_num_filters_legacy(layer_attributes: WeightedLayerAttributes)
- layer_attributes.get_target_dim_for_compression -> 
get_target_dim_for_compression_legacy(layer_attributes:
WeightedLayerAttributes)
- layer_attributes.get_weight_shape -> 
get_weight_shape_legacy(layer_attributes: WeightedLayerAttributes)


2. Calls to above class methods were replaced with calls to their
corresponding legacy functions in the following locations
- /nncf/experimental/common/ folder
  - pruning/nodes_grouping.py
- /nncf/experimental/tensorflow/ folder
  - quantization/algorithm.py
- /nncf/experimental/torch/ folder
  - nas/bootstrapNAS/elasticity/elastic_width.py
  - sparsity/movement/layers.py
  - sparsity/movement/structured_mask_handler.py
- /nncf/torch/ folder
  - quantization/algo.py
  - quantization/init_range.py
  - sparsity/const/algo.py
  - sparsity/magnitude/algo.py
  - sparsity/rb/algo.py


### Reason for changes

Torch and Tensorflow backend-specific methods need to be removed 
from common layer attributes and all related calls need to be replaced 
by their corresponding legacy function calls (resolves openvinotoolkit#3249)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
Status: Closed
Development

Successfully merging a pull request may close this issue.

2 participants