Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

[WIP] Pytorch v1.2 #1093

Closed
wants to merge 5 commits into from
Closed

[WIP] Pytorch v1.2 #1093

wants to merge 5 commits into from

Conversation

botcs
Copy link
Contributor

@botcs botcs commented Sep 17, 2019

Main issue is uint8 / bool.
unit tests are passing, except checkpointer test: had to modify since the expected behavior of nn.DataParallel has changed.

Feel free to add any modifications

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Sep 17, 2019
@qizhuli
Copy link
Contributor

qizhuli commented Oct 11, 2019

I was wondering if it would make more sense to dynamically check pytorch version, and choose torch.bool or torch.uint8, so that the code remains backward compatible, and fewer nasty surprises when updating codebase/pytorch? Could be done by replacing torch.uint8 (in places where they are used for indexing) with a simple helper function mask_dtype(), which looks like this:

import torch
from maskrcnn_benchmark.somewhere import get_version

def mask_dtype():
    major, minor = get_version(torch)[:2]
    if major * 100 + minor * 10 >= 120:
        return torch.bool
    else:
        return torch.uint8

and put this helper function in somewhere:

def get_version(module):
    version = getattr(module, '__version__').split('.')
    parsed_version = []
    for v in version:
        try:
            v = int(v)
            parsed_version.append(v)
        except ValueError:
            parsed_version.append(-1)
    return parsed_version

This can also be used to dynamically control the place we call scheduler.step(), whose behaviour changed in pytorch 1.1.

@botcs
Copy link
Contributor Author

botcs commented Oct 16, 2019

I like the idea, but I think the same amount of effort would be more useful in adding a few convenience features in detectron2.

There are a lot of stuff still here waiting for cleanup, also detectron2

@botcs botcs closed this Oct 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed Do not delete this pull request or issue due to inactivity. contributions welcome
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants