-
Notifications
You must be signed in to change notification settings - Fork 249
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
[NNCF] (#3249) Remove backend-specific methods from common layer attributes #3287
[NNCF] (#3249) Remove backend-specific methods from common layer attributes #3287
Conversation
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
…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
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
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
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
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
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shumaari, thank you for the contribution! Please remove the redundant get_weights_shape
, get_target_dim_for_compression
and get_bias_shape
methods from the Layer attributes
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
@daniil-lyakhov done! |
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
@daniil-lyakhov I have added the missing import statements which might fix the error in linter and pytest. Could you please rerun the checks? thank you! |
Removed abstract class methods from common layer attributes in nncf/common/graph/layer_attributes.py - get_weight_shape - get_target_dim_for_compression 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
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_num_filters -> get_num_filters_legacy(layer_attributes: WeightedLayerAttributes) 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
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_num_filters -> get_num_filters_legacy(layer_attributes: WeightedLayerAttributes) Locations in /nncf/experimental/torch/nas/bootstrapNAS/elasticity/ folder - elastic_width.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
Removed backend-specific class method from common layer attributes in nncf/common/graph/layer_attributes.py - get_num_filters 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
Refactoring and formatting changes 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
Refactoring and formatting changes 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
Refactoring and formatting changes 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
@daniil-lyakhov I have made some changes, could you please check again? Thank you so much for the hand-holding! :) |
@daniil-lyakhov could you please clarify which option is correct:
Thank you |
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/ folder - quantization/algo.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
@daniil-lyakhov I have made some changes, could you please check once more? Thank you! |
Changes: done.
Changes: done.
@daniil-lyakhov Thanks for the feedback, changes are done. Is there anything else required before merging? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shumaari, thank you for your updates! Please address my last minor comments and convert PR to a non draft one. I'll start review process with the NNCF team
Changes: done.
@daniil-lyakhov Thank you for all your help! I would like to work on another issue, please let me know which one. 👍 |
@ljaljushkin, @AlexanderDokuchaev, please share your opinion on this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…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)
Changes
attributes in nncf/common/graph/layer_attributes.py to self-contained
functions in nncf/common/graph/utils.py
get_bias_shape_legacy(layer_attributes: WeightedLayerAttributes)
get_num_filters_legacy(layer_attributes: WeightedLayerAttributes)
get_target_dim_for_compression_legacy(layer_attributes: WeightedLayerAttributes)
get_weight_shape_legacy(layer_attributes: WeightedLayerAttributes)
corresponding legacy functions in the following locations
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)