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

Fix argwhere bug #5816

Merged
merged 7 commits into from
Aug 10, 2021
Merged

Fix argwhere bug #5816

merged 7 commits into from
Aug 10, 2021

Conversation

BBuf
Copy link
Contributor

@BBuf BBuf commented Aug 9, 2021

解决下面的问题:

图片

图片

@BBuf BBuf requested a review from leaves-zwx August 9, 2021 15:08
size.to_local().numpy().item()
if size.is_consistent
else size.numpy().item()
)
Copy link
Contributor

Choose a reason for hiding this comment

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

这里的处理我想了下,也会有问题,argwhere 应该也不能支持 input 为 consistent,因为这个计算求出来的 res 里面的 nd-index 一定是 local 的,size 也是。所以改成:

if input.is_consistent:
    raise ValueError("A consistent tensor can not be applied to argwhere, and use `tensor.to_local()` to convert it to local tensor first.")

(res, size) = flow.F.argwhere(input, dtype=dtype)
if input.is_lazy:
    raise NotImplementedError
    # return flow.F.sync_dynamic_resize(res, size, dim=0)
else:
    slice_tup_list = [(0, size.numpy().item(), 1)]
    return flow.slice(res, slice_tup_list=slice_tup_list)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的

@oneflow-ci-bot oneflow-ci-bot removed their request for review August 10, 2021 03:55
@oneflow-ci-bot oneflow-ci-bot self-requested a review August 10, 2021 03:55
@BBuf BBuf requested review from oneflow-ci-bot and removed request for oneflow-ci-bot August 10, 2021 06:13
@oneflow-ci-bot oneflow-ci-bot removed their request for review August 10, 2021 06:32
@oneflow-ci-bot oneflow-ci-bot self-requested a review August 10, 2021 06:32
@github-actions
Copy link
Contributor

Speed stats:
GPU Name: GeForce GTX 1080 

PyTorch resnet50 time: 140.5ms (= 7024.9ms / 50, input_shape=[16, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 128.2ms (= 6409.6ms / 50, input_shape=[16, 3, 224, 224], backward is enabled)
Relative speed: 1.10 (= 140.5ms / 128.2ms)

PyTorch resnet50 time: 84.2ms (= 4210.3ms / 50, input_shape=[8, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 74.4ms (= 3720.6ms / 50, input_shape=[8, 3, 224, 224], backward is enabled)
Relative speed: 1.13 (= 84.2ms / 74.4ms)

PyTorch resnet50 time: 61.3ms (= 3062.6ms / 50, input_shape=[4, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 51.2ms (= 2558.1ms / 50, input_shape=[4, 3, 224, 224], backward is enabled)
Relative speed: 1.20 (= 61.3ms / 51.2ms)

PyTorch resnet50 time: 48.3ms (= 2415.7ms / 50, input_shape=[2, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 40.4ms (= 2022.0ms / 50, input_shape=[2, 3, 224, 224], backward is enabled)
Relative speed: 1.19 (= 48.3ms / 40.4ms)

PyTorch resnet50 time: 43.6ms (= 2180.0ms / 50, input_shape=[1, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 43.5ms (= 2174.9ms / 50, input_shape=[1, 3, 224, 224], backward is enabled)
Relative speed: 1.00 (= 43.6ms / 43.5ms)

@oneflow-ci-bot oneflow-ci-bot removed their request for review August 10, 2021 08:30
@oneflow-ci-bot oneflow-ci-bot merged commit 52dd6e3 into master Aug 10, 2021
@oneflow-ci-bot oneflow-ci-bot deleted the fix_argwhere_bug branch August 10, 2021 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants