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

Auto-detect feature layer for Pytorch models #64

Merged

Conversation

goodsong81
Copy link
Contributor

@goodsong81 goodsong81 commented Sep 6, 2024

[Changes]

  • Feature layer auto detection (by lazy one-time forward hook)
    • CNNs: the last layer which outputs 4D maps w/ spatial dimension
    • ViTs: the N-last LayerNorm layer
      (Different from OV logic as there is no explicit Add module just before the LayerNorm in Pytorch models)

[Future works]

  • Refactoring + torch optional install
  • Documentation + example
  • Functional tests

Copy link

codecov bot commented Sep 6, 2024

Codecov Report

Attention: Patch coverage is 96.07843% with 2 lines in your changes missing coverage. Please review.

Project coverage is 94.23%. Comparing base (8b0ddf9) to head (6617ccb).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
openvino_xai/methods/white_box/torch.py 96.07% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #64      +/-   ##
===========================================
+ Coverage    94.16%   94.23%   +0.07%     
===========================================
  Files           27       27              
  Lines         1817     1857      +40     
===========================================
+ Hits          1711     1750      +39     
- Misses         106      107       +1     
Flag Coverage Δ
dev-py310 94.23% <96.07%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@goodsong81 goodsong81 force-pushed the feat/torch-layer-detect branch from bac4363 to 2e97454 Compare September 9, 2024 07:56
@goodsong81 goodsong81 marked this pull request as ready for review September 9, 2024 08:20
@goodsong81 goodsong81 added this to the 1.1.0 milestone Sep 9, 2024
openvino_xai/methods/white_box/torch.py Outdated Show resolved Hide resolved
openvino_xai/methods/white_box/torch.py Outdated Show resolved Hide resolved
openvino_xai/methods/white_box/torch.py Outdated Show resolved Hide resolved
openvino_xai/methods/white_box/torch.py Show resolved Hide resolved
openvino_xai/methods/white_box/torch.py Outdated Show resolved Hide resolved
openvino_xai/methods/white_box/torch.py Outdated Show resolved Hide resolved
negvet
negvet previously approved these changes Sep 9, 2024
Copy link
Collaborator

@negvet negvet left a comment

Choose a reason for hiding this comment

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

Validation on a large scope of models is the best way to see how such kind of changes generalize. I see you plan to do it as the future work.

@GalyaZalesskaya GalyaZalesskaya merged commit 04d5d52 into openvinotoolkit:develop Sep 10, 2024
6 checks passed
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.

3 participants