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

[Types] Fix misleading List[Tensor] types #2535

Merged
merged 2 commits into from
Jan 31, 2023
Merged

[Types] Fix misleading List[Tensor] types #2535

merged 2 commits into from
Jan 31, 2023

Conversation

siddancha
Copy link
Contributor

Motivation

A few functions in the following files:

  • decode_head.py
  • encoder_decoder.py
  • cascade_encoder_decoder.py

have a return type annotation as List[Tensor] whereas their actual return type is Tensor. This can be seen by following the trace of what each functions return internally, which eventually leads to seg_logits: Tensor.

This type annotation is misleading and confusing when a user is trying to read and understand the code.

Modification

  1. Fix type annotations from List[Tensor] to Tensor.
  2. Make a return type more specific from list to SampleList.

Checklist

  • Pre-commit or other linting tools are used to fix the potential lint issues.
    • I've fixed all linting/pre-commit errors.
  • The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
    • This involves only changing type annotations, so there is no need for tests.
  • If the modification has potential influence on downstream projects, this PR should be tested with downstream projects, like MMDet or MMDet3D.
    • I don't think this change affects MMDet or MMDet3D.
  • The documentation has been modified accordingly, like docstring or example tutorials.
    • This change fixes existing type annotations, so it may require a change in the documentation/docstring that I don't have access to.

This is the return type of predict() which returns postprocess_result()
@codecov
Copy link

codecov bot commented Jan 31, 2023

Codecov Report

Base: 83.40% // Head: 83.40% // No change to project coverage 👍

Coverage data is based on head (89b809b) compared to base (18ee41e).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##              1.x    #2535   +/-   ##
=======================================
  Coverage   83.40%   83.40%           
=======================================
  Files         145      145           
  Lines        8510     8510           
  Branches     1274     1274           
=======================================
  Hits         7098     7098           
  Misses       1198     1198           
  Partials      214      214           
Flag Coverage Δ
unittests 83.40% <ø> (ø)

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

Impacted Files Coverage Δ
mmseg/models/decode_heads/decode_head.py 93.85% <ø> (ø)
mmseg/models/segmentors/base.py 90.14% <ø> (ø)
mmseg/models/segmentors/cascade_encoder_decoder.py 91.48% <ø> (ø)
mmseg/models/segmentors/encoder_decoder.py 90.08% <ø> (ø)
mmseg/datasets/transforms/transforms.py 90.40% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@MeowZheng MeowZheng merged commit e7b3d17 into open-mmlab:1.x Jan 31, 2023
@siddancha siddancha deleted the sid/pr/fix-list-types-1.x branch January 31, 2023 16:01
@siddancha
Copy link
Contributor Author

siddancha commented Jan 31, 2023

Looks like I accidentally created this PR for 1.x branch, and not dev-1.x. Is this a problem? Should we merge 1.x backwards to dev-1.x so that both are synced?

MeowZheng added a commit that referenced this pull request Feb 1, 2023
## Motivation

This is essentially #2535 that I had intended to submit to the `dev-1.x`
branch but accidentally submitted it directly to the `1.x` branch
(apologies!). This also got approved possibly because the core devs also
didn't realize this.

The problem is that now `1.x` and `dev-1.x` are out of sync -- the
changes introduced by #2535 will never be reflected in `dev-1.x`.

## Modification

I'm proposing this "backward-merge" so that `1.x` and `dev-1.x` can be
in sync again. If you look at "files changed", they are exactly the
changes introduced by #2535.

Co-authored-by: MeowZheng <meowzheng@outlook.com>
nahidnazifi87 pushed a commit to nahidnazifi87/mmsegmentation_playground that referenced this pull request Apr 5, 2024
…2546)

## Motivation

This is essentially open-mmlab#2535 that I had intended to submit to the `dev-1.x`
branch but accidentally submitted it directly to the `1.x` branch
(apologies!). This also got approved possibly because the core devs also
didn't realize this.

The problem is that now `1.x` and `dev-1.x` are out of sync -- the
changes introduced by open-mmlab#2535 will never be reflected in `dev-1.x`.

## Modification

I'm proposing this "backward-merge" so that `1.x` and `dev-1.x` can be
in sync again. If you look at "files changed", they are exactly the
changes introduced by open-mmlab#2535.

Co-authored-by: MeowZheng <meowzheng@outlook.com>
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