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

list indexing use scalar tensor #7597

Merged
merged 19 commits into from
Feb 28, 2022
Merged

Conversation

Flowingsun007
Copy link
Contributor

@Flowingsun007 Flowingsun007 commented Feb 25, 2022

y = np.arange(num)
for i in range(num):
x = flow.tensor(i, dtype=dtype)
test_case.assertTrue(np.allclose(i, y[x]))
Copy link
Contributor

Choose a reason for hiding this comment

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

这里是不是可以直接 test_case.assertEqual

以及 y 可以是一个随机 list,这里判断 y[i] 和 y[x] 的相等性

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

@Flowingsun007 Flowingsun007 enabled auto-merge (squash) February 25, 2022 03:09
@github-actions
Copy link
Contributor

Code got formatted by CI. Please request CI again if you still want to have this PR merged. If the PR is from a forked repo, please download the patch files from the GitHub Actions web page and apply them locally.

@Flowingsun007 Flowingsun007 requested review from oneflow-ci-bot and removed request for oneflow-ci-bot February 25, 2022 03:16
@oneflow-ci-bot oneflow-ci-bot removed their request for review February 25, 2022 04:30
@oneflow-ci-bot oneflow-ci-bot self-requested a review February 25, 2022 07:31
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot February 25, 2022 09:22
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot February 25, 2022 11:13
@github-actions
Copy link
Contributor

CI failed when running job: cpu-misc. PR label automerge has been removed

@oneflow-ci-bot oneflow-ci-bot removed their request for review February 26, 2022 01:41
@github-actions
Copy link
Contributor

Code got formatted by CI. Please request CI again if you still want to have this PR merged. If the PR is from a forked repo, please download the patch files from the GitHub Actions web page and apply them locally.

@oneflow-ci-bot oneflow-ci-bot removed their request for review February 26, 2022 05:15
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot February 26, 2022 05:15
@oneflow-ci-bot oneflow-ci-bot self-requested a review February 26, 2022 08:42
@github-actions
Copy link
Contributor

Speed stats:
GPU Name: GeForce GTX 1080 

✔️ OneFlow resnet50 time: 128.7ms (= 12871.2ms / 100, input_shape=[16, 3, 224, 224])
PyTorch resnet50 time: 140.2ms (= 14021.4ms / 100, input_shape=[16, 3, 224, 224])
✔️ Relative speed: 1.09 (= 140.2ms / 128.7ms)

❌ OneFlow resnet50 time: 79.6ms (= 7957.3ms / 100, input_shape=[8, 3, 224, 224])
PyTorch resnet50 time: 83.6ms (= 8361.8ms / 100, input_shape=[8, 3, 224, 224])
✔️ Relative speed: 1.05 (= 83.6ms / 79.6ms)

OneFlow resnet50 time: 52.9ms (= 10572.0ms / 200, input_shape=[4, 3, 224, 224])
PyTorch resnet50 time: 57.2ms (= 11432.7ms / 200, input_shape=[4, 3, 224, 224])
✔️ Relative speed: 1.08 (= 57.2ms / 52.9ms)

OneFlow resnet50 time: 44.4ms (= 8883.2ms / 200, input_shape=[2, 3, 224, 224])
PyTorch resnet50 time: 48.9ms (= 9782.7ms / 200, input_shape=[2, 3, 224, 224])
✔️ Relative speed: 1.10 (= 48.9ms / 44.4ms)

OneFlow resnet50 time: 38.9ms (= 7780.5ms / 200, input_shape=[1, 3, 224, 224])
PyTorch resnet50 time: 41.9ms (= 8383.9ms / 200, input_shape=[1, 3, 224, 224])
✔️ Relative speed: 1.08 (= 41.9ms / 38.9ms)

✔️ OneFlow resnet50 time: 142.7ms (= 14266.2ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 161.5ms (= 16152.8ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.13 (= 161.5ms / 142.7ms)

OneFlow resnet50 time: 91.8ms (= 9182.0ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 105.0ms (= 10498.1ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.14 (= 105.0ms / 91.8ms)

OneFlow resnet50 time: 61.4ms (= 12280.1ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 76.2ms (= 15248.3ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.24 (= 76.2ms / 61.4ms)

OneFlow resnet50 time: 52.2ms (= 10435.9ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 65.0ms (= 13005.3ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.25 (= 65.0ms / 52.2ms)

OneFlow resnet50 time: 47.0ms (= 9395.8ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 61.1ms (= 12211.5ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.30 (= 61.1ms / 47.0ms)

@github-actions
Copy link
Contributor

CI failed when running job: cuda-speed-test. PR label automerge has been removed

@oneflow-ci-bot oneflow-ci-bot removed their request for review February 26, 2022 10:08
@github-actions
Copy link
Contributor

Speed stats:
GPU Name: GeForce GTX 1080 

✔️ OneFlow resnet50 time: 128.4ms (= 12843.6ms / 100, input_shape=[16, 3, 224, 224])
PyTorch resnet50 time: 141.1ms (= 14105.5ms / 100, input_shape=[16, 3, 224, 224])
✔️ Relative speed: 1.10 (= 141.1ms / 128.4ms)

✔️ OneFlow resnet50 time: 78.7ms (= 7873.2ms / 100, input_shape=[8, 3, 224, 224])
PyTorch resnet50 time: 86.8ms (= 8680.2ms / 100, input_shape=[8, 3, 224, 224])
✔️ Relative speed: 1.10 (= 86.8ms / 78.7ms)

OneFlow resnet50 time: 52.0ms (= 10407.9ms / 200, input_shape=[4, 3, 224, 224])
PyTorch resnet50 time: 58.5ms (= 11707.3ms / 200, input_shape=[4, 3, 224, 224])
✔️ Relative speed: 1.12 (= 58.5ms / 52.0ms)

OneFlow resnet50 time: 41.2ms (= 8238.3ms / 200, input_shape=[2, 3, 224, 224])
PyTorch resnet50 time: 44.0ms (= 8809.5ms / 200, input_shape=[2, 3, 224, 224])
✔️ Relative speed: 1.07 (= 44.0ms / 41.2ms)

OneFlow resnet50 time: 39.0ms (= 7798.4ms / 200, input_shape=[1, 3, 224, 224])
PyTorch resnet50 time: 38.7ms (= 7736.3ms / 200, input_shape=[1, 3, 224, 224])
✔️ Relative speed: 0.99 (= 38.7ms / 39.0ms)

✔️ OneFlow resnet50 time: 142.1ms (= 14208.6ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 160.6ms (= 16055.4ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.13 (= 160.6ms / 142.1ms)

OneFlow resnet50 time: 88.8ms (= 8877.8ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 103.1ms (= 10307.6ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.16 (= 103.1ms / 88.8ms)

OneFlow resnet50 time: 61.6ms (= 12327.6ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 73.8ms (= 14763.9ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.20 (= 73.8ms / 61.6ms)

OneFlow resnet50 time: 49.9ms (= 9984.3ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 70.6ms (= 14128.2ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.42 (= 70.6ms / 49.9ms)

OneFlow resnet50 time: 48.6ms (= 9714.3ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 64.1ms (= 12829.7ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.32 (= 64.1ms / 48.6ms)

@oneflow-ci-bot oneflow-ci-bot removed their request for review February 26, 2022 13:07
@github-actions
Copy link
Contributor

Speed stats:
GPU Name: GeForce GTX 1080 

✔️ OneFlow resnet50 time: 128.4ms (= 12840.5ms / 100, input_shape=[16, 3, 224, 224])
PyTorch resnet50 time: 139.6ms (= 13955.9ms / 100, input_shape=[16, 3, 224, 224])
✔️ Relative speed: 1.09 (= 139.6ms / 128.4ms)

✔️ OneFlow resnet50 time: 76.7ms (= 7665.5ms / 100, input_shape=[8, 3, 224, 224])
PyTorch resnet50 time: 86.1ms (= 8614.1ms / 100, input_shape=[8, 3, 224, 224])
✔️ Relative speed: 1.12 (= 86.1ms / 76.7ms)

OneFlow resnet50 time: 50.9ms (= 10178.4ms / 200, input_shape=[4, 3, 224, 224])
PyTorch resnet50 time: 61.6ms (= 12315.1ms / 200, input_shape=[4, 3, 224, 224])
✔️ Relative speed: 1.21 (= 61.6ms / 50.9ms)

OneFlow resnet50 time: 40.7ms (= 8137.3ms / 200, input_shape=[2, 3, 224, 224])
PyTorch resnet50 time: 43.4ms (= 8670.6ms / 200, input_shape=[2, 3, 224, 224])
✔️ Relative speed: 1.07 (= 43.4ms / 40.7ms)

OneFlow resnet50 time: 39.8ms (= 7963.3ms / 200, input_shape=[1, 3, 224, 224])
PyTorch resnet50 time: 41.0ms (= 8193.1ms / 200, input_shape=[1, 3, 224, 224])
✔️ Relative speed: 1.03 (= 41.0ms / 39.8ms)

✔️ OneFlow resnet50 time: 141.6ms (= 14162.0ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 159.1ms (= 15912.8ms / 100, input_shape=[16, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.12 (= 159.1ms / 141.6ms)

OneFlow resnet50 time: 90.6ms (= 9063.9ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 103.9ms (= 10393.5ms / 100, input_shape=[8, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.15 (= 103.9ms / 90.6ms)

OneFlow resnet50 time: 63.3ms (= 12657.9ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 76.7ms (= 15348.4ms / 200, input_shape=[4, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.21 (= 76.7ms / 63.3ms)

OneFlow resnet50 time: 52.1ms (= 10420.1ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 64.5ms (= 12897.1ms / 200, input_shape=[2, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.24 (= 64.5ms / 52.1ms)

OneFlow resnet50 time: 49.0ms (= 9796.1ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
PyTorch resnet50 time: 59.6ms (= 11923.7ms / 200, input_shape=[1, 3, 224, 224], ddp, world size=2)
✔️ Relative speed: 1.22 (= 59.6ms / 49.0ms)

@Flowingsun007 Flowingsun007 merged commit 99897b4 into master Feb 28, 2022
@Flowingsun007 Flowingsun007 deleted the use_scalar_tensor_as_list_index branch February 28, 2022 03:36
marigoold pushed a commit that referenced this pull request Mar 15, 2022
* list indexing use scalar tensor

* refine

* refine
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.

4 participants