Skip to content

Conversation

daniil-lyakhov
Copy link
Collaborator

@daniil-lyakhov daniil-lyakhov commented Oct 1, 2021

  • Have separated common parts of pruning export_helpers
  • Implement base realization of mask_propogation methods to have opportunity to use mask propagation algo without any specific framework(tf, torch) functions.

The main point of this refactoring is mask propagation algo with framework agnostic masks support. Thus we will be allowed to use mask propogation algo at model analyzing stage to check state: "Every prunable layer have correspondent closing prunable layer". Thus we will be able to propagate masks through reshape layers and will enable one of a realization of SE block in mobilenet_v3. For this, numpy arrays will be propagated by base realization of mask_propogation

TODO:

  • Implement tests to cover common and algo specific mask propogation

@mkaglins
Copy link
Contributor

mkaglins commented Oct 1, 2021

@daniil-lyakhov Please, define what is closing prunable layer in PR description and add more details about why is it needed.

@daniil-lyakhov
Copy link
Collaborator Author

@daniil-lyakhov Please, define what is closing prunable layer in PR description and add more details about why is it needed.

Every prunable layer L should have closing prunable layer means next prunable layer after L which input channels are pruning.

For example:
image

Green group is group of prunable layers, which has same channel dimention. We are removing some output channels from them. And yellow prunable layer is closing prunable layer which input channels we are removing. Hope this helped

@daniil-lyakhov daniil-lyakhov force-pushed the dl/refactor_export_helpers branch from ccb0597 to 7c40fc1 Compare October 5, 2021 08:34
Comment on lines 184 to 190
if input_node.data.get('output_mask', None) is not None:
continue

source_nodes = get_sources_of_node(input_node, graph, cls.ConvolutionOp.get_all_op_aliases() +
cls.StopMaskForwardOp.get_all_op_aliases() +
cls.InputOp.get_all_op_aliases())
sources_types = [node.node_type for node in source_nodes] + [input_node.node_type]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please be aware of two changes here:

if input_node.data.get('output_mask', None) is not None:

instead of

if input_node.data.get('output_mask', None) is None:

and

sources_types = [node.node_type for node in source_nodes] + [input_node.node_type]

instead of

sources_types = [node.node_type for node in source_nodes]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daniil-lyakhov Please, describe how the second change (of sources_types) will impact how the algorithm works on known models with Concat.

And, please, test these changes carefully on these models.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, please check daniil-lyakhov#10

Copy link
Collaborator Author

@daniil-lyakhov daniil-lyakhov Oct 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have run tests on CI #969

@daniil-lyakhov daniil-lyakhov force-pushed the dl/refactor_export_helpers branch from ba7140a to e022a1f Compare October 5, 2021 10:42
@daniil-lyakhov
Copy link
Collaborator Author

daniil-lyakhov commented Oct 5, 2021

Minor TODO:

  • Process torch.stask

@daniil-lyakhov
Copy link
Collaborator Author

Jenkins please retry a build

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.
"""
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we remove this module and use 'common module in the TensorFlow backend?

if mask is None:
concat_axis = node.layer_attributes.axis
concat_dim = input_edges[i].tensor_shape[concat_axis]
device = cls._get_masks_device(input_masks)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please explain what type of mask? Can we avoid functions as _get_masks_device?

@daniil-lyakhov daniil-lyakhov force-pushed the dl/refactor_export_helpers branch from 23a4ff1 to 0712dff Compare October 8, 2021 15:57
@daniil-lyakhov daniil-lyakhov force-pushed the dl/refactor_export_helpers branch from 0712dff to 9dd421a Compare October 8, 2021 16:00
@daniil-lyakhov
Copy link
Collaborator Author

daniil-lyakhov commented Oct 8, 2021

Three major changes:

  • export_helpers was renamed to pruning_operations da26217
  • NNCFTensor was introduced to use only common entities into mask propagation 8d586a8
  • check_concat method was removed as we discussed 9dd421a

@daniil-lyakhov daniil-lyakhov force-pushed the dl/refactor_export_helpers branch 4 times, most recently from 648b4f2 to 4340499 Compare October 11, 2021 11:13
@daniil-lyakhov daniil-lyakhov force-pushed the dl/refactor_export_helpers branch from 0a972d2 to 5c46689 Compare October 14, 2021 09:20
@alexsu52 alexsu52 merged commit f42355d into openvinotoolkit:develop Oct 15, 2021
kshpv pushed a commit to kshpv/nncf that referenced this pull request Oct 11, 2022
* Have separated common parts of pruning export_helpers 
* Implement base realization of `mask_propogation` methods to have opportunity to use mask propagation algo without any specific framework(tf, torch) functions. 

The main point of this refactoring is mask propagation algo with framework agnostic masks support. Thus we will be allowed to use mask propogation algo at model analyzing stage to check state: "Every prunable layer have correspondent closing prunable layer". Thus we will be able to propagate masks through reshape layers and will enable one of a realization of SE block in mobilenet_v3. For this, numpy arrays will be propagated by base realization of `mask_propogation`

TODO:

- [x] Implement tests to cover common and algo specific mask propogation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants