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

Support 0shape tensor #5620

Merged
merged 42 commits into from Aug 1, 2021
Merged

Support 0shape tensor #5620

merged 42 commits into from Aug 1, 2021

Conversation

wyg1997
Copy link
Contributor

@wyg1997 wyg1997 commented Jul 27, 2021

本PR支持 0shape Tensor的创建、计算,例如:

x = flow.ones((4, 0, 4))
y = flow.ones((4, 2, 4))
z = flow.cat([x, y], dim=1)
print(z.shape)  # flow.Size([4, 2, 4])

TODO

相关issue

#5399 #5537

wyg1997 and others added 27 commits July 27, 2021 12:56
Signed-off-by: daquexian <daquexian566@gmail.com>
…feat-0shape_tensor

Conflicts:
	python/oneflow/framework/tensor.py
…feat-0shape_tensor

Conflicts:
	python/oneflow/test/modules/test_acos.py
	python/oneflow/test/modules/test_acosh.py
	python/oneflow/test/modules/test_atan.py
	python/oneflow/test/modules/test_atan2.py
	python/oneflow/test/modules/test_atanh.py
	python/oneflow/test/modules/test_tan.py
	python/oneflow/test_utils/automated_test_util/torch_flow_dual_object.py
@wyg1997 wyg1997 requested review from oneflow-ci-bot and removed request for oneflow-ci-bot July 31, 2021 10:49
@github-actions
Copy link
Contributor

CI failed, removing label automerge

@oneflow-ci-bot oneflow-ci-bot removed their request for review July 31, 2021 11:22
@wyg1997 wyg1997 requested review from oneflow-ci-bot and removed request for oneflow-ci-bot July 31, 2021 11:33
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot August 1, 2021 04:28
@github-actions
Copy link
Contributor

github-actions bot commented Aug 1, 2021

Speed stats:
GPU Name: GeForce GTX 1080 

PyTorch resnet50 time: 137.5ms (= 6877.0ms / 50, input_shape=[16, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 126.9ms (= 6343.2ms / 50, input_shape=[16, 3, 224, 224], backward is enabled)
Relative speed: 1.08 (= 137.5ms / 126.9ms)

PyTorch resnet50 time: 83.5ms (= 4176.4ms / 50, input_shape=[8, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 76.7ms (= 3836.1ms / 50, input_shape=[8, 3, 224, 224], backward is enabled)
Relative speed: 1.09 (= 83.5ms / 76.7ms)

PyTorch resnet50 time: 57.1ms (= 2854.8ms / 50, input_shape=[4, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 48.8ms (= 2442.3ms / 50, input_shape=[4, 3, 224, 224], backward is enabled)
Relative speed: 1.17 (= 57.1ms / 48.8ms)

PyTorch resnet50 time: 45.7ms (= 2287.0ms / 50, input_shape=[2, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 43.2ms (= 2158.5ms / 50, input_shape=[2, 3, 224, 224], backward is enabled)
Relative speed: 1.06 (= 45.7ms / 43.2ms)

PyTorch resnet50 time: 43.5ms (= 2175.3ms / 50, input_shape=[1, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 41.9ms (= 2097.2ms / 50, input_shape=[1, 3, 224, 224], backward is enabled)
Relative speed: 1.04 (= 43.5ms / 41.9ms)

@oneflow-ci-bot oneflow-ci-bot removed their request for review August 1, 2021 05:42
@oneflow-ci-bot oneflow-ci-bot merged commit d57de62 into master Aug 1, 2021
@oneflow-ci-bot oneflow-ci-bot deleted the feat-0shape_tensor branch August 1, 2021 05:43
const auto& slice = index_item.slice();
int64_t step = std::min(slice.step(), shape.At(dim));
CHECK_GT_OR_RETURN(step, 0) << "Step must be greater than zero.";
Copy link
Contributor

Choose a reason for hiding this comment

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

这个不应该删吧,我们就是不支持负数step

Copy link
Contributor

Choose a reason for hiding this comment

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

这个不应该删吧,我们就是不支持负数step

已修改

oneflow/core/functional/tensor_index.cpp Show resolved Hide resolved
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

6 participants