Skip to content

refactor efficientnet output tracing with @capture_outputs and @can_r…#44072

Open
Siddhartha7340 wants to merge 1 commit intohuggingface:mainfrom
Siddhartha7340:efficientnet
Open

refactor efficientnet output tracing with @capture_outputs and @can_r…#44072
Siddhartha7340 wants to merge 1 commit intohuggingface:mainfrom
Siddhartha7340:efficientnet

Conversation

@Siddhartha7340
Copy link
Copy Markdown

@Siddhartha7340 Siddhartha7340 commented Feb 17, 2026

Refactor efficientnet output tracing

What does this PR do?

This Pull Request migrates the EfficientNet model to use the standardized @capture_outputs and @can_return_tuple decorators.

  • Added _can_record_outputs to EfficientNetPreTrainedModel.
  • Added @caputre_outputs to the base model forward in this case to EfficientNetModel.forward.
  • Applied @can_return_tuple on higher-level forwards in this case to EfficientNetForImageClassification.forward.
  • Droped output_attentions, output_hidden_states, return_dict from signatures
  • Removed parameter resolution lines and manual collection loops

Closes #43979 for efficientnet.

Validation

  • ran python3 -m compileall src/transformers/models/resnet/modeling_resnet.py
  • ran pytest tests/models/efficientnet -x -v -k "not test_save_load"
    (note: used "not test_save_load" because on Windows, I encountered a safetensors I/O serialization error causing test_save_load to fail locally. All other EfficientNet tests pass on my setup.)
Screenshot 2026-02-17 120710

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

@molbap @yonigozlan

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@github-actions
Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: efficientnet

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.

Call to contributions: refactor output tracing in transformers

1 participant